qradar


Nameqradar JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/Chmele/qradar-client
SummaryQRadar client for python with API schema fetching
upload_time2024-11-16 12:25:31
maintainerNone
docs_urlNone
authorChmele
requires_pythonNone
licenseMIT
keywords client scripting qradar qradar-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # QRadar API python client for scripting

> python3.10 and above supported

Features:
- Pulls API schema from QRadar and creates client methods dynamically for the API version specified. This makes this client source code as small as possible;
- Asyncronous and client with schema caching introduced
- All the endpoints of QRadar API is mapped to a client method by name;
- No dependencies introduced, tested with httpx and requests http protocol libs with dependency injection, but obviously will only work with libs that provide compatible requests-like interface for Session-like object. Of course, wrappers can help with using incompatible libs;
- Generates stub file for method hinting if needed. It takes ~10MB of disk space.

## Installation

`pip install qradar`

 or with requests/httpx correspondingly:

`pip install qradar[requests]`

`pip install qradar[httpx]`

## Intended usage
Made to be used as full-featured copypaste drop-in client for scripts where pip installation way be unwanted. Of course, it is not prohibited to install this package with pip.

## How to use any client (refer to examples for more)
0) Use any of `import` statements:
```python
from qradar import QRadar, QRadarAsync, QRadarCached
```
or copy the coppersonding `qradar/client.py` file contents
1) Initialize client as following:
```python
q = QRadar("https://qradar.is.local", KEY, "22.0", requests.Session(), verify=False) 
```
Having:
- qradar.is.local is QRadar console hostname or ip
- KEY is API key created from console
- `"22.0"` - replaced with API version you want
- `requests` imported (and installed)

> Also works with httpx, with minor differences. Refer to examples for details

2) Use client instance methods, forming the name of desired endpoint

>For example, the endpoint `22.0 - GET - /reference_data/map_of_sets` is referenced by name `q.get_reference_data_map_of_sets`. The http method goes first, and the API endpoint path is trailing it, having the slashes replaced with underscores.

> For endpoints such as `22.0 - GET - /reference_data/map_of_sets/{name}` use the `reference_data_map_of_sets_name`, with {name} part provided as keyword argument:
> `q.get_reference_data_map_of_sets_name(name='refmapofsetsname')`

> For params such as filter, use keyword arguments:
> `q.help_endpoint(filter=f"version={version}")`

> For data posting, use first non-keyword argument. It accepts json-serializable objects (lists, dicts, lists of dicts, etc.):
> `q.post_reference_data_map_of_sets({"data": ["data"]})`

## Generating .pyi file for intellisense
This option may be used for setting up more convenient development environment. Final script version should be delivered without API schema.

1) Clone the repository into project folder
2) Run `python3 schema_prefetch.py` having correct parameters in source code
3) `client.pyi` file must appear. As far as it is in one folder with `client.py`, the methods will be hinted with the names, arguments and description from QRadar API schema

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Chmele/qradar-client",
    "name": "qradar",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "client, scripting, qradar, qradar-api",
    "author": "Chmele",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/bb/f4/244bb89f871a7eace8c0a1363093b3d3154ce49978fd76cc9945e72edfe8/qradar-0.0.2.tar.gz",
    "platform": null,
    "description": "# QRadar API python client for scripting\n\n> python3.10 and above supported\n\nFeatures:\n- Pulls API schema from QRadar and creates client methods dynamically for the API version specified. This makes this client source code as small as possible;\n- Asyncronous and client with schema caching introduced\n- All the endpoints of QRadar API is mapped to a client method by name;\n- No dependencies introduced, tested with httpx and requests http protocol libs with dependency injection, but obviously will only work with libs that provide compatible requests-like interface for Session-like object. Of course, wrappers can help with using incompatible libs;\n- Generates stub file for method hinting if needed. It takes ~10MB of disk space.\n\n## Installation\n\n`pip install qradar`\n\n or with requests/httpx correspondingly:\n\n`pip install qradar[requests]`\n\n`pip install qradar[httpx]`\n\n## Intended usage\nMade to be used as full-featured copypaste drop-in client for scripts where pip installation way be unwanted. Of course, it is not prohibited to install this package with pip.\n\n## How to use any client (refer to examples for more)\n0) Use any of `import` statements:\n```python\nfrom qradar import QRadar, QRadarAsync, QRadarCached\n```\nor copy the coppersonding `qradar/client.py` file contents\n1) Initialize client as following:\n```python\nq = QRadar(\"https://qradar.is.local\", KEY, \"22.0\", requests.Session(), verify=False) \n```\nHaving:\n- qradar.is.local is QRadar console hostname or ip\n- KEY is API key created from console\n- `\"22.0\"` - replaced with API version you want\n- `requests` imported (and installed)\n\n> Also works with httpx, with minor differences. Refer to examples for details\n\n2) Use client instance methods, forming the name of desired endpoint\n\n>For example, the endpoint `22.0 - GET - /reference_data/map_of_sets` is referenced by name `q.get_reference_data_map_of_sets`. The http method goes first, and the API endpoint path is trailing it, having the slashes replaced with underscores.\n\n> For endpoints such as `22.0 - GET - /reference_data/map_of_sets/{name}` use the `reference_data_map_of_sets_name`, with {name} part provided as keyword argument:\n> `q.get_reference_data_map_of_sets_name(name='refmapofsetsname')`\n\n> For params such as filter, use keyword arguments:\n> `q.help_endpoint(filter=f\"version={version}\")`\n\n> For data posting, use first non-keyword argument. It accepts json-serializable objects (lists, dicts, lists of dicts, etc.):\n> `q.post_reference_data_map_of_sets({\"data\": [\"data\"]})`\n\n## Generating .pyi file for intellisense\nThis option may be used for setting up more convenient development environment. Final script version should be delivered without API schema.\n\n1) Clone the repository into project folder\n2) Run `python3 schema_prefetch.py` having correct parameters in source code\n3) `client.pyi` file must appear. As far as it is in one folder with `client.py`, the methods will be hinted with the names, arguments and description from QRadar API schema\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "QRadar client for python with API schema fetching",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/Chmele/qradar-client"
    },
    "split_keywords": [
        "client",
        " scripting",
        " qradar",
        " qradar-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62a9fda1d9efcc61889da81f4218d03641f59c701cf81067d53382ecd19372c5",
                "md5": "605d05f4ed88c99151274cd7f55e1d89",
                "sha256": "ca9d5b5e0812ebd10b37102dbc26577d1dc647bf6cacd02649971f48a1fa0186"
            },
            "downloads": -1,
            "filename": "qradar-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "605d05f4ed88c99151274cd7f55e1d89",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4734,
            "upload_time": "2024-11-16T12:25:30",
            "upload_time_iso_8601": "2024-11-16T12:25:30.131760Z",
            "url": "https://files.pythonhosted.org/packages/62/a9/fda1d9efcc61889da81f4218d03641f59c701cf81067d53382ecd19372c5/qradar-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbf4244bb89f871a7eace8c0a1363093b3d3154ce49978fd76cc9945e72edfe8",
                "md5": "a4cb80455c311b23308489f152c8fb17",
                "sha256": "817a19158c7448d8ab5b0a4a89be4f8c0c8c92d2ccbc09a19c71a072765b9418"
            },
            "downloads": -1,
            "filename": "qradar-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a4cb80455c311b23308489f152c8fb17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5199,
            "upload_time": "2024-11-16T12:25:31",
            "upload_time_iso_8601": "2024-11-16T12:25:31.524003Z",
            "url": "https://files.pythonhosted.org/packages/bb/f4/244bb89f871a7eace8c0a1363093b3d3154ce49978fd76cc9945e72edfe8/qradar-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 12:25:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Chmele",
    "github_project": "qradar-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "qradar"
}
        
Elapsed time: 1.23157s