Skip to main content

A client library for accessing opsduty

Project description

opsduty-client

A client library for accessing opsduty

Usage

First, create a client:

from opsduty_client import Client

client = Client(base_url="https://opsduty.io")

If the endpoints you're going to hit require authentication, use AuthenticatedClient instead:

from opsduty_client import AuthenticatedClient

client = AuthenticatedClient(base_url="https://opsduty.io", token="oAuth2 access token")

Now call your endpoint and use your models:

from opsduty_client.models import MyDataModel
from opsduty_client.api.my_tag import get_my_data_model
from opsduty_client.types import Response

with client as client:
    my_data: MyDataModel = get_my_data_model.sync(client=client)
    # or if you need more info (e.g. status_code)
    response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)

Or do the same thing with an async version:

from opsduty_client.models import MyDataModel
from opsduty_client.api.my_tag import get_my_data_model
from opsduty_client.types import Response

async with client as client:
    my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
    response: Response[MyDataModel] = await get_my_data_model.asyncio_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 opsduty_client 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://opsduty.io",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):

import httpx
from opsduty_client import Client

client = Client(
    base_url="https://opsduty.io",
)
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
client.set_httpx_client(httpx.Client(base_url="https://opsduty.io", proxies="http://localhost:8030"))

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

opsduty_client-0.0.3a2.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

opsduty_client-0.0.3a2-py3-none-any.whl (64.8 kB view details)

Uploaded Python 3

File details

Details for the file opsduty_client-0.0.3a2.tar.gz.

File metadata

  • Download URL: opsduty_client-0.0.3a2.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0

File hashes

Hashes for opsduty_client-0.0.3a2.tar.gz
Algorithm Hash digest
SHA256 ba02911e02fc2fd8dee45cb5555605bde91aa2c4d7246e70fed19cddba8fef14
MD5 d9da65639a1b100db30ba63489fb7b6d
BLAKE2b-256 2af51ba4d5cc424c15dfa4a92d1c82f95712b18990a66b042b903c0f50daf5fe

See more details on using hashes here.

File details

Details for the file opsduty_client-0.0.3a2-py3-none-any.whl.

File metadata

File hashes

Hashes for opsduty_client-0.0.3a2-py3-none-any.whl
Algorithm Hash digest
SHA256 bd06658f66f1931d8624bb049fa53ec11cd1651312891292e1642c708b5d37a1
MD5 f794c72c78d52499ab744999f06f5233
BLAKE2b-256 bc37f030d43655ff85b11dd1afc7e5d99aa6814259e1ca618de9fbf3e6effb7a

See more details on using hashes here.

Supported by

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