QRadar API python client for scripting
[!IMPORTANT] python3.10 and above supported.
http libs such as requests or httpx should be installed separately or as optional packages, as described below.
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
[!TIP] Made to be used as full-featured copypaste drop-in client for scripts where pip installation way be unwanted. Clients are used this way in examples.
Of course, it is not prohibited to install this package with pip.
How to use any client (refer to examples for more)
- Use any of
importstatements:
from qradar import QRadar, QRadarAsync, QRadarCached
or copy the coppersonding qradar/client.py file contents
- Initialize client as following:
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 wantrequestsimported (and installed)
Also works with httpx, with minor differences. Refer to examples for details
- Use client instance methods, forming the name of desired endpoint
For example, the endpoint
22.0 - GET - /reference_data/map_of_setsis referenced by nameq.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 thereference_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
- Clone the repository into project folder
- Run
python3 schema_prefetch.pyhaving correct parameters in source code client.pyifile must appear. As far as it is in one folder withclient.py, the methods will be hinted with the names, arguments and description from QRadar API schema
Metadata
Release files for qradar 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qradar-0.0.4.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qradar-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / qradar-0.0.4.tar.gz
| Download URL | qradar-0.0.4.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0eeae39a69aee2193cba4f4f899ac8448fc159843812e11b9328dfb72f506196
|
|
BLAKE2b-256 checksum How to use checksums |
55077e09bb6b0c81bdc57487fac37495b5c715bac4c62f226ad96532558a8306
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / qradar-0.0.4-py3-none-any.whl
| Download URL | qradar-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3db4db74fb99f39cfc4b8151e7a399964b0f95982313f911742ee52c9b633f4
|
|
BLAKE2b-256 checksum How to use checksums |
a4010484ed00852d911890aad33941b2e39b34d421d152b5fb5716dc3fb13b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|