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(azure_client_id: str, azure_application_id: str, azure_login_url: HttpUrl | str | None = None, azure_client_secret: str | None = None, *, use_managed_identity: bool = False)[source]#
Auth middleware that handles OAuth2 token retrieval and refresh.
This is generally used in conjunction with
OAuthClient.Supports three authentication flows:
Public Client Application (human login)
Initial login will be interactive through a browser window. Subsequent token retrievals will use cached tokens and refreshes where possible, and only prompt for login again if necessary.
auth = OAuthMiddleware( azure_client_id="client-id", azure_application_id="login-url", azure_tenant_id="tenant-id", )
Confidential Client Application (client credentials)
Suitable for service-to-service authentication where no user interaction is possible or desired. Reach out if you need help setting up a confidential client application. The secret must be stored securely.
auth = OAuthMiddleware( azure_client_id="client-id", azure_application_id="application-id", azure_login_url="login-url", azure_client_secret="your-azure-client-secret", )
Azure Managed Identity
Suitable for Azure environments that have had API permissions provisioned for their managed identity. Note that the
azure_client_idhere is the client ID of the managed identity, not the repository.auth = OAuthMiddleware( azure_client_id="your-managed-identity-client-id", azure_application_id="application-id", use_managed_identity=True, )
- class libs.sdk.src.destiny_sdk.client.OAuthClient(base_url: HttpUrl | str, auth: Auth | 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, OAuthMiddleware 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]) 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.
- 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, sort: str | None = None, page: int = 1) 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.
sort (str | None) – The sort order for the results.
page (int) – The page number of results to retrieve.
- Returns:
The response from the API.
- Return type: