Skip to main content

Python client library for accessing the ISDuBA API

Project description

ISDuBA Python Client

A client library for accessing ISDuBA API, based on code generated by https://github.com/openapi-generators/openapi-python-client and adapted to ISDuBA-specific needs.

Usage

First, create a client instance:

from isduba import Client

client = Client(base_url="https://isduba.example.com")

Then, login with your credentials:

client.login(username='ada', password='bob')

Now call your endpoint and use your models:

from isduba.api.default import get_about

about = get_about.sync(client=client)
# access the response's value as attributes:
about.version
# or if you need more info (e.g. status_code)
response = get_about.sync_detailed(client=client)

Or do the same thing with an async version:

from isduba.api.default import get_about

about = await get_about.asyncio(client=client)
response = await get_about.asyncio_detailed(client=client)

Get documents

from isduba.api.default import get_documents

data = get_documents.sync(client=client, advisories=True, count=1, orders='-critical', limit=10, offset=0)
# search for a string
get_documents.sync(client=client, query='"csaf" search _clientSearch as')
# search for a product. Query syntax: https://github.com/ISDuBA/ISDuBA/blob/main/docs/filter_expr.md
data = get_documents.sync(client=client, query='"putty" ilikepname', limit=2)

Usage Logic

Things to know:

  1. Every path/method combo becomes a Python module with four functions:

    1. sync: Blocking request that returns parsed data (if successful) or None
    2. sync_detailed: Blocking request that always returns a Request, optionally with parsed set if the request was successful.
    3. asyncio: Like sync but async instead of blocking
    4. asyncio_detailed: Like sync_detailed but async instead of blocking
  2. All path/query params, and bodies become method arguments.

  3. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)

  4. Any endpoint which did not have a tag will be in isduba.api.default

Typing

All responses are objects, you can add typing information with the models:

from isduba.models import WebAboutInfo
from isduba.api.default import get_about
from isduba.types import Response

about: WebAboutInfo = get_about.sync(client=client)
# access the response's value as attributes:
about.version
# or if you need more info (e.g. status_code)
response: Response[WebAboutInfo] = get_about.sync_detailed(client=client)

Advanced customizations

There are more settings on the generated Client class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying httpx.Client or httpx.AsyncClient (depending on your use-case):

from isduba import Client

def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client = Client(
    base_url="https://isduba.example.com",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isduba-0.1.0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isduba-0.1.0-py3-none-any.whl (167.6 kB view details)

Uploaded Python 3

File details

Details for the file isduba-0.1.0.tar.gz.

File metadata

  • Download URL: isduba-0.1.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for isduba-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63380110bdea86342776b3ec30a216d7075b5bf2a0091003bea5e28ca9a722e6
MD5 929671ffd7251c3ecbab7bf56347bc0a
BLAKE2b-256 e1db00e121301a002633041910538c464e6147c471297d2d37076159679d7142

See more details on using hashes here.

File details

Details for the file isduba-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: isduba-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 167.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for isduba-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6a543a41d8b35403ba52f13207791e2016f9f49222415e07da85a032f01a8af
MD5 223bee0215d951db80a7b29b8747f5e0
BLAKE2b-256 5a041f650e1a9cba0aa1e13f4822cc91b394c5965ad5b9ae1650ef73f66488be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page