pygleif.v2.base.Transport¶
- class pygleif.v2.base.Transport(base_url='https://api.gleif.org/api/v1', *, timeout=10.0, retries=3, httpx_transport=None, httpx_async_transport=None)[source]¶
Perform GET requests against the GLEIF JSON API, sync or async.
- Parameters:
- __init__(base_url='https://api.gleif.org/api/v1', *, timeout=10.0, retries=3, httpx_transport=None, httpx_async_transport=None)[source]¶
Init the transport.
retriesis the number of extra attempts for transient failures (RETRY_STATUSESand network-level errors), honoringRetry-Afterwith the delay capped atMAX_RETRY_DELAY_SECONDS; pass0to disable retries. Thehttpx_*transporthooks exist mainly so tests can inject anhttpx2.MockTransport.
Methods
__aenter__()Enter the async context manager.
__aexit__(*exc_info)Close the async client on context exit.
__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__enter__()Enter the sync context manager.
__eq__(value, /)Return self==value.
__exit__(*exc_info)Close the sync client on context exit.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__getstate__()Helper for pickle.
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init__([base_url, timeout, retries, ...])Init the transport.
__init_subclass__()This method is called when a class is subclassed.
__le__(value, /)Return self<=value.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(*args, **kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__(object, /)Abstract classes can override this to customize issubclass().
_arequest(path[, params, base_url, accept])Async counterpart of
_request()._asend_with_retry(url, headers)Async counterpart of
_send_with_retry()._build_url(path[, params, base_url])Compose a full request URL with an encoded query string.
_decode_json(response)Decode a response body as JSON, mapping decode failures.
_map_status_error(exc)Map an
httpx2status error to the v2 error hierarchy._request(path[, params, base_url, accept])Issue a GET request, mapping failures to the v2 errors.
_send_with_retry(url, headers)GET with up to
self.retriesextra attempts on transient errors.aclose()Close the underlying async client, if one was created.
aget(path[, params])Issue an async GET request and return the decoded JSON body.
aget_raw(path[, params, base_url])Issue an async GET request and return the raw response body.
close()Close the underlying sync client, if one was created.
get(path[, params])Issue a GET request and return the decoded JSON body.
get_raw(path[, params, base_url])Issue a GET request and return the raw response body.
Attributes
__annotations____dict____doc____firstlineno____module____static_attributes____weakref__list of weak references to the object
async_clientReturn the lazily-created
httpx2.AsyncClient.clientReturn the lazily-created sync
httpx2.Client.