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:
  • base_url (str)

  • timeout (float)

  • retries (int)

  • httpx_transport (httpx.BaseTransport | None)

  • httpx_async_transport (httpx.AsyncBaseTransport | None)

__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.

retries is the number of extra attempts for transient failures (RETRY_STATUSES and network-level errors), honoring Retry-After with the delay capped at MAX_RETRY_DELAY_SECONDS; pass 0 to disable retries. The httpx_*transport hooks exist mainly so tests can inject an httpx.MockTransport.

Parameters:
  • base_url (str)

  • timeout (float)

  • retries (int)

  • httpx_transport (BaseTransport | None)

  • httpx_async_transport (AsyncBaseTransport | None)

Return type:

None

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 httpx status 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.retries extra 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_client

Return the lazily-created httpx.AsyncClient.

client

Return the lazily-created sync httpx.Client.