katana_public_api_client.client¶
katana_public_api_client.client
¶
Classes¶
AuthenticatedClient
¶
A Client which has been authenticated for use on secured endpoints
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Functions¶
__aenter__()
async
¶
Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)
__aexit__(*args, **kwargs)
async
¶
Exit a context manager for underlying httpx.AsyncClient (see httpx docs)
__enter__()
¶
Enter a context manager for self.client—you cannot enter twice (see httpx docs)
__exit__(*args, **kwargs)
¶
Exit a context manager for internal httpx.Client (see httpx docs)
get_async_httpx_client()
¶
Get the underlying httpx.AsyncClient, constructing a new one if not previously set
Source code in katana_public_api_client/client.py
get_httpx_client()
¶
Get the underlying httpx.Client, constructing a new one if not previously set
Source code in katana_public_api_client/client.py
set_async_httpx_client(async_client)
¶
Manually the underlying httpx.AsyncClient
NOTE: This will override any other settings on the client, including cookies, headers, and timeout.
Source code in katana_public_api_client/client.py
set_httpx_client(client)
¶
Manually set the underlying httpx.Client
NOTE: This will override any other settings on the client, including cookies, headers, and timeout.
Source code in katana_public_api_client/client.py
with_cookies(cookies)
¶
Get a new client matching this one with additional cookies
Source code in katana_public_api_client/client.py
with_headers(headers)
¶
Get a new client matching this one with additional headers
Source code in katana_public_api_client/client.py
with_timeout(timeout)
¶
Get a new client matching this one with a new timeout (in seconds)
Source code in katana_public_api_client/client.py
Client
¶
A class for keeping track of data related to the API
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Functions¶
__aenter__()
async
¶
Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)
__aexit__(*args, **kwargs)
async
¶
Exit a context manager for underlying httpx.AsyncClient (see httpx docs)
__enter__()
¶
Enter a context manager for self.client—you cannot enter twice (see httpx docs)
__exit__(*args, **kwargs)
¶
Exit a context manager for internal httpx.Client (see httpx docs)
get_async_httpx_client()
¶
Get the underlying httpx.AsyncClient, constructing a new one if not previously set
Source code in katana_public_api_client/client.py
get_httpx_client()
¶
Get the underlying httpx.Client, constructing a new one if not previously set
Source code in katana_public_api_client/client.py
set_async_httpx_client(async_client)
¶
Manually the underlying httpx.AsyncClient
NOTE: This will override any other settings on the client, including cookies, headers, and timeout.
Source code in katana_public_api_client/client.py
set_httpx_client(client)
¶
Manually set the underlying httpx.Client
NOTE: This will override any other settings on the client, including cookies, headers, and timeout.
Source code in katana_public_api_client/client.py
with_cookies(cookies)
¶
Get a new client matching this one with additional cookies
Source code in katana_public_api_client/client.py
with_headers(headers)
¶
Get a new client matching this one with additional headers
Source code in katana_public_api_client/client.py
with_timeout(timeout)
¶
Get a new client matching this one with a new timeout (in seconds)