ai_api_client_sdk package

Subpackages

Submodules

ai_api_client_sdk.ai_api_v2_client module

class AIAPIV2Client

Bases: object

The AIAPIV2Client is the class implemented to interact with the AI API server. The user can use its attributes corresponding to the resources, for interacting with endpoints related to that resource. (i.e., aiapiv2client.scenario)

Parameters:
  • base_url (str) -- Base URL of the AI API server. Should include the base path as well. (i.e., "<base_url>/scenarios" should work)

  • auth_url (str, optional) -- URL of the authorization endpoint. Should be the full URL (including /oauth/token), defaults to None

  • client_id (str, optional) -- client id to be used for authorization, defaults to None

  • client_secret (str, optional) -- client secret to be used for authorization, defaults to None

  • cert_str (str, optional) -- certificate file content, needs to be provided alongside the key_str parameter, defaults to None

  • key_str (str, optional) -- key file content, needs to be provided alongside the cert_str parameter, defaults to None

  • cert_file_path (str, optional) -- path to the certificate file, needs to be provided alongside the key_file_path parameter, defaults to None

  • key_file_path (str, optional) -- path to the key file, needs to be provided alongside the cert_file_path parameter, defaults to None

  • token_creator (Callable[[], str], optional) -- the function which returns the Bearer token, when called. Either this, or auth_url & client_id & client_secret should be specified, defaults to None

  • resource_group (str, optional) -- The default resource group which will be used while sending the requests to the server. If not set, the resource_group should be specified with every request to the server, defaults to None

  • read_timeout (int) -- Read timeout for requests in seconds, defaults to 60s

  • connect_timeout (int) -- Connect timeout for requests in seconds, defaults to 60s

  • num_request_retries (int) -- Number of retries for failing requests with http status code 429, 500, 502, 503 or 504, defaults to 60s

  • client_type (str) -- Client type header to be sent in the request, defaults to 'AI API Python SDK'

__init__(base_url, auth_url=None, client_id=None, client_secret=None, cert_str=None, key_str=None, cert_file_path=None, key_file_path=None, token_creator=None, resource_group=None, connect_timeout=60, num_request_retries=3, **kwargs)
Parameters:
  • base_url (str)

  • auth_url (str)

  • client_id (str)

  • client_secret (str)

  • cert_str (str)

  • key_str (str)

  • cert_file_path (str)

  • key_file_path (str)

  • token_creator (Callable[[], str])

  • resource_group (str)

ai_api_client_sdk.exception module

exception AIAPIAuthenticatorAuthorizationException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with unauthorized when trying to retrieve a token

__init__(error_message=None)
Parameters:

error_message (str)

exception AIAPIAuthenticatorException

Bases: AIAPIClientSDKException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator

__init__(status_code=None, error_message=None)
Parameters:
  • status_code (int)

  • error_message (str)

exception AIAPIAuthenticatorForbiddenException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with forbidden when trying to retrieve a token

__init__(error_message=None)
Parameters:

error_message (str)

exception AIAPIAuthenticatorInvalidRequestException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with bad request when trying to retrieve a token

__init__(error_message=None)
Parameters:

error_message (str)

exception AIAPIAuthenticatorMethodNotAllowedException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with method not allowed when trying to retrieve a token

__init__(error_message=None)
Parameters:

error_message (str)

exception AIAPIAuthenticatorServerException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with server error when trying to retrieve a token

__init__(status_code=None, error_message=None)
Parameters:
  • status_code (int)

  • error_message (str)

exception AIAPIAuthenticatorTimeoutException

Bases: AIAPIAuthenticatorException

Exception type that is raised by the ai_api_client_sdk.helpers.authenticator.Authenticator if the XSUAA server responded with request timeout when trying to retrieve a token

__init__(error_message=None)
Parameters:

error_message (str)

exception AIAPIAuthorizationException

Bases: AIAPIServerException

Exception type that is raised by the ai_api_client_sdk.helpers.rest_client.RestClient if a 401 response is received from the server. This extends the ai_api_client_sdk.exception.AIAPIServerException, refer there for object definition

__init__(description, error_message, error_code=None, request_id=None, details=None)
Parameters:
  • description (str)

  • error_message (str)

  • error_code (str)

  • request_id (str)

  • details (dict)

exception AIAPIClientSDKException

Bases: Exception

Base Exception class for AI API Client SDK exceptions

__init__(description, status_code=None, error_message=None)
Parameters:
  • description (str)

  • status_code (int)

  • error_message (str)

exception AIAPIInvalidInputException

Bases: AIAPIClientSDKException

Exception type raised, when the provided input is invalid

__init__(description)
Parameters:

description (str)

exception AIAPIInvalidRequestException

Bases: AIAPIServerException

Exception type that is raised by the ai_api_client_sdk.helpers.rest_client.RestClient if a 400 response is received from the server. This extends the ai_api_client_sdk.exception.AIAPIServerException, refer there for object definition

__init__(description, error_code, error_message, request_id, details=None)
Parameters:
  • description (str)

  • error_code (str)

  • error_message (str)

  • request_id (str)

  • details (dict)

exception AIAPINotFoundException

Bases: AIAPIServerException

Exception type that is raised by the ai_api_client_sdk.helpers.rest_client.RestClient if a 404 response is received from the server. This extends the ai_api_client_sdk.exception.AIAPIServerException, refer there for object definition

__init__(description, error_code, error_message, request_id, details=None)
Parameters:
  • description (str)

  • error_code (str)

  • error_message (str)

  • request_id (str)

  • details (dict)

exception AIAPIPreconditionFailedException

Bases: AIAPIServerException

Exception type that is raised by the ai_api_client_sdk.helpers.rest_client.RestClient if a 412 response is received from the server. This extends the ai_api_client_sdk.exception.AIAPIServerException, refer there for object definition

__init__(description, error_code, error_message, request_id, details=None)
Parameters:
  • description (str)

  • error_code (str)

  • error_message (str)

  • request_id (str)

  • details (dict)

exception AIAPIServerException

Bases: Exception

Exception type that is raised by the ai_api_client_sdk.helpers.rest_client.RestClient, if a non-2XX response is received from the server.

Parameters:
  • description (str) -- description of the exception

  • status_code (int) -- Status code of the response from the server

  • error_message (str) -- Error message received from the server

  • error_code (str, optional) -- Error code received from the server, defaults to None

  • request_id (str, optional) -- ID of the request, the response belongs to, defaults to None

  • details (dict, optional) -- Error details received from the server, defaults to None

__init__(description, status_code, error_message, error_code=None, request_id=None, details=None)
Parameters:
  • description (str)

  • status_code (int)

  • error_message (str)

  • error_code (str)

  • request_id (str)

  • details (dict)