SDK Client#
This documentation auto-generates details about the OAuth authentication and convenience methods provided by the SDK for users.
Note
The required configuration values (eg IDs) can be found at OAuth.
- class libs.sdk.src.destiny_sdk.client.OAuthMiddleware(env: Literal['development', 'staging', 'production'] | None = None, auth_url: str = 'https://auth.evidence-repository.org', realm: str = 'destiny', client_id: str | None = None, client_secret: SecretStr | None = None, scopes: list[str] | None = None, callback_port: int = 8400, azure_client_id: str | None = None, azure_application_id: str | None = None, azure_login_url: HttpUrl | str | None = None, azure_client_secret: SecretStr | None = None, *, use_managed_identity: bool = False)[source]#
Auth middleware that routes to either Keycloak or Azure OAuth backends.
The backend is selected by which kwargs are provided:
Keycloak (default): the routing target unless any Azure kwarg is given.
env(recommended) orclient_idis required.Azure AD: pass any
azure_*kwarg oruse_managed_identity=True. Managed identity is supported. The interactive (public-client) and confidential-client (azure_client_secret) flows are deprecated and will be removed in a future release; migrate those callers to Keycloak.
# Interactive login for user accounts auth = OAuthMiddleware(env="production") # Client credentials flow for service accounts auth = OAuthMiddleware( client_id="your-client-id", client_secret="your-client-secret" )
- class libs.sdk.src.destiny_sdk.client.OAuthClient(base_url: HttpUrl | str | None = None, auth: Auth | None = None, timeout: int = 10, *, env: Literal['development', 'staging', 'production'] | None = None)[source]#
Client for interaction with the Destiny API using OAuth2.
This will apply the provided authentication, usually
OAuthMiddleware, to all requests. Some API endpoints are supported directly through methods on this class, while others can be accessed through the underlyinghttpxclient.Example usage:
from destiny_sdk.client import OAuthClient # Either use env for defaults or provide explicit auth and base_url client = OAuthClient(env="production") client = OAuthClient( base_url="https://destiny-repository.example.com", auth=OAuthMiddleware(...), ) # Supported method response = client.search(query="example") # Unsupported method, use underlying httpx client response = client.get_client().get("/system/healthcheck/")
- get_client() Client[source]#
Get the underlying
httpxclient.This can be used to make custom requests not covered by the SDK methods.
- Returns:
The underlying
httpxclient with authentication attached.- Return type:
- lookup(identifiers: list[str | IdentifierLookup], timeout: int | None = None) list[Reference][source]#
Lookup references by identifiers.
See also: API Lookup.
- Parameters:
identifiers (list[str | libs.sdk.src.destiny_sdk.identifiers.IdentifierLookup]) – The identifiers to look up.
timeout (int | None) – The timeout for the request, in seconds. If provided, this will override the client timeout.
- Returns:
The list of references matching the identifiers.
- Return type:
- search(query: str, start_year: int | None = None, end_year: int | None = None, annotations: list[str | AnnotationFilter] | None = None, concepts: list[str | Collection[str]] | None = None, sort: str | None = None, page: int = 1, timeout: int | None = None) ReferenceSearchResult[source]#
Send a search request to the Destiny Repository API.
See also: API Query String Search.
- Parameters:
query (str) – The search query string.
start_year (int | None) – The start year for filtering results.
end_year (int | None) – The end year for filtering results.
annotations (list[str | libs.sdk.src.destiny_sdk.search.AnnotationFilter] | None) – A list of annotation filters to apply.
concepts (list[str | collections.abc.Collection[str]] | None) – A list of linked-data concept filters. Each entry ANDs with the others. Pass a single URI string for a single match, or a collection of URIs to OR them within a single filter.
sort (str | None) – The sort order for the results.
page (int) – The page number of results to retrieve.
timeout (int | None) – The timeout for the request, in seconds. If provided, this will override the client timeout.
- Returns:
The response from the API.
- Return type: