A client library for accessing Brigid API.
First, create a client:
from brigid_api_client import AuthenticatedClient
client = AuthenticatedClient(base_url="https://brigid-prod.api.caltech.edu", token="SuperSecretToken")
Now call your endpoint and use your models. Example::
from brigid_api_client.models import Organization
from brigid_api_client.api.organizations import organizations_retrieve
from brigid_api_client.types import Response
org: Organization = organizations_retrieve.sync(client=client, id=1)
# or if you need more info (e.g. status_code)
response: Response[Organization] = organizations_retrieve.sync_detailed(client=client, id=1)
Or do the same thing with an async version:
from brigid_api_client.models import Organization
from brigid_api_client.async_api.organizations import organizations_retrieve
from brigid_api_client.types import Response
org: Organization = await organizations_retrieve.asyncio(client=client, id=1)
response: Response[Organization] = await organizations_retrieve.asyncio_detailed(client=client, id=1)
Things to know:
-
Every path/method combo becomes a Python module with four functions:
sync
: Blocking request that returns parsed data (if successful) orNone
sync_detailed
: Blocking request that always returns aRequest
, optionally withparsed
set if the request was successful.asyncio
: Likesync
but the async instead of blockingasyncio_detailed
: Likesync_detailed
by async instead of blocking
-
All path/query params, and bodies become method arguments.
-
If your endpoint had any tags on it, the first tag will be used as a module name for the function (e.g.
organzations
above) -
Any endpoint which did not have a tag will be in
brigid_api_client.api.default
First you should have openapi-python-client
installed into your global python interpreter.
$ cd ..
$ wget --no-check-certificate -O schema.yml https://localhost:8063/api/v1/schema/
$ openapi-python-client update --path schema.yml --custom-template-path=./brigid-api-client/templates/