Skip to content

orca_sdk.credentials#

Scope module-attribute #

Scope = Literal['ADMINISTER', 'PREDICT']

The scopes of an API key.

  • ADMINISTER: Can do anything, including creating and deleting organizations, models, and API keys.
  • PREDICT: Can only call model.predict and perform CRUD operations on predictions.

ApiKeyInfo #

Bases: NamedTuple

Named tuple containing information about an API key

Attributes:

  • name (str) –

    Unique name of the API key

  • created_at (datetime) –

    When the API key was created

OrcaCredentials #

Class for managing Orca API credentials

get_api_url staticmethod #

get_api_url()

Get the Orca API base URL that is currently being used

list_api_keys staticmethod #

list_api_keys()

List all API keys that have been created for your org

Returns:

  • list[ApiKeyInfo]

    A list of named tuples, with the name and creation date time of the API key

is_authenticated staticmethod #

is_authenticated()

Check if you are authenticated to interact with the Orca API

Returns:

  • bool

    True if you are authenticated, False otherwise

create_api_key staticmethod #

create_api_key(name, scopes={'ADMINISTER'})

Create a new API key with the given name and scopes

Parameters:

  • name (str) –

    The name of the API key

  • scopes (set[Scope], default: {'ADMINISTER'} ) –

    The scopes of the API key

Returns:

  • str

    The secret value of the API key. Make sure to save this value as it will not be shown again.

revoke_api_key staticmethod #

revoke_api_key(name)

Delete an API key

Parameters:

  • name (str) –

    The name of the API key to delete

Raises:

set_headers staticmethod #

set_headers(headers)

Add or override default HTTP headers for all Orca API requests.

Parameters:

  • headers (dict[str, str]) –

    Mapping of header names to their string values

Notes

New keys are merged into the existing headers, this will overwrite headers with the same name, but leave other headers untouched.

set_api_key staticmethod #

set_api_key(api_key, check_validity=True)

Set the API key to use for authenticating with the Orca API

Note

The API key can also be provided by setting the ORCA_API_KEY environment variable

Parameters:

  • api_key (str) –

    The API key to set

  • check_validity (bool, default: True ) –

    Whether to check if the API key is valid and raise an error otherwise

Raises:

  • ValueError

    if the API key is invalid and check_validity is True

set_base_url staticmethod #

set_base_url(base_url, check_validity=True)

Set the base URL for the Orca API

Parameters:

  • base_url (str) –

    The base URL to set

  • check_validity (bool, default: True ) –

    Whether to check if there is an API running at the given base URL

Raises:

  • ValueError

    if there is no healthy API running at the given base URL and check_validity is True

is_healthy staticmethod #

is_healthy()

Check whether the API is healthy

Returns:

  • bool

    True if the API is healthy, False otherwise