Skip to main content

A client library for accessing Drata's open API

Project description

drata-python-api-client

A client library for accessing The Drata public API

Usage

First, create a client:

from drata_python_api_client.models import (
    UserResponsePublicDto, ExceptionResponsePublicDto
)
from drata_python_api_client import AuthenticatedClient

drata_client = AuthenticatedClient(region="EU", token="VeryMuchSecureToken")

Now call your endpoint and use your models:

from drata_python_api_client.api.users import users_public_controller_get_user_by_email

user: UserResponsePublicDto = users_public_controller_get_user_by_email.sync(
    client=drata_client,
    email="some@email.com",
)

Or do the same thing with an async version:

from drata_python_api_client.models import (
    UserResponsePublicDto, ExceptionResponsePublicDto
)
from drata_python_api_client.api.users import users_public_controller_get_user_by_email

async with client as client:
    Union[
        BackgroundCheckResponsePublicDto, 
        ExceptionResponsePublicDto
    ] = await users_public_controller_get_user_by_email.asyncio(client=client, email="some@email.com")

Advanced customizations

There are more settings on the generated AuthenticatedClient 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 drata_python_api_client import AuthenticatedClient

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 = AuthenticatedClient(
    region="EU",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

Building / publishing this package

If you want to install this client into another project without publishing it (e.g. for development) then:

  1. If that project is using Poetry, you can simply do poetry add <path-to-this-client> from that project
  2. If that project is not using Poetry:
    1. Build a wheel with poetry build -f wheel
    2. Install that wheel from the other project pip install <path-to-wheel>

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

drata_python_api_client-1.1.4.tar.gz (267.1 kB view details)

Uploaded Source

Built Distribution

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

drata_python_api_client-1.1.4-py3-none-any.whl (703.5 kB view details)

Uploaded Python 3

File details

Details for the file drata_python_api_client-1.1.4.tar.gz.

File metadata

  • Download URL: drata_python_api_client-1.1.4.tar.gz
  • Upload date:
  • Size: 267.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Darwin/24.6.0

File hashes

Hashes for drata_python_api_client-1.1.4.tar.gz
Algorithm Hash digest
SHA256 b1c40db80aa57cad4bdc83c08714e18f08e52c9b3ea46e6d8db471b65fa07d43
MD5 2a21f293ccfe2106977b8bcc7eb7d1fa
BLAKE2b-256 c84f2b49adc4cf5f72637dcdef676e22366cf4f77dffaa13b43db13dc464de5c

See more details on using hashes here.

File details

Details for the file drata_python_api_client-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for drata_python_api_client-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1d1b46962a9b500599ddba9662074630d5c9dad38bdf3fe32e401f7ff03b201a
MD5 2ced0c9f7f7efd6aa50b9086ed9ce7f5
BLAKE2b-256 044ff4b6d287a51b3a77231c73a863aa125e1c2776653e179547f77caa62c937

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