datadog_api_client.v1

exception ApiAttributeError(msg, path_to_item=None)

Bases: OpenApiException, AttributeError

Raised when an attribute reference or assignment fails.

Parameters:
  • msg (str) – The exception message.

  • path_to_item (list) – The path to the exception in the received_data dict. None if unset.

class ApiClient(configuration: Configuration)

Bases: object

Generic API client for OpenAPI client library builds.

OpenAPI generic API client. This client handles the client- server communication, and is invariant across implementations. Specifics of the methods and models for each application are generated from the OpenAPI templates.

Parameters:
  • configuration – Configuration object for this client

  • header_name – A header to pass when making calls to the API.

  • header_value – A header value to pass when making calls to the API.

call_api(resource_path: str, method: str, path_params: Dict[str, Any] | None = None, query_params: List[Tuple[str, Any]] | None = None, header_params: Dict[str, Any] | None = None, body: Any | None = None, post_params: List[Tuple[str, Any]] | None = None, files: Dict[str, List[FileIO]] | None = None, response_type: Tuple[Any] | None = None, return_http_data_only: bool | None = None, collection_formats: Dict[str, str] | None = None, preload_content: bool = True, request_timeout: int | float | Tuple[int | float, int | float] | None = None, host: str | None = None, check_type: bool | None = None)

Makes the HTTP request (synchronous) and returns deserialized data.

Parameters:
  • resource_path – Path to method endpoint.

  • method – Method to call.

  • path_params – Path parameters in the url.

  • query_params – Query parameters in the url.

  • header_params – Header parameters to be placed in the request header.

  • body – Request body.

  • dict (post_params) – Request post form parameters, for application/x-www-form-urlencoded, multipart/form-data.

  • response_type – For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple of valid classes as the value Example values: (str,) (Pet,) (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},)

  • files (dict) – key -> field name, value -> a list of open file objects for multipart/form-data.

  • return_http_data_only (bool, optional) – response data without head status code and headers

  • collection_formats (dict, optional) – dict of collection formats for path, query, header, and post parameters.

  • preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • check_type (bool, optional) – boolean describing if the data back from the server should have its type checked.

Returns:

the HTTP response.

deserialize(response_data: str, response_type: Any, check_type: bool | None)

Deserializes response into an object.

Parameters:
  • response_data – Response data to be deserialized.

  • response_type – For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple of valid classes as the value Example values: (str,) (Pet,) (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},)

  • check_type (bool) – boolean, whether to check the types of the data received from the server

Returns:

deserialized object.

files_parameters(files: Dict[str, List[FileIO]] | None = None)

Builds form parameters.

Parameters:

files – None or a dict with key=param_name and value is a list of open file objects

Returns:

List of tuples of form parameters with file data

parameters_to_multipart(params)

Get parameters as list of tuples, formatting as json if value is dict.

Parameters:

params – Parameters as list of two-tuples.

Returns:

Parameters as list of tuple or urllib3.fields.RequestField

parameters_to_tuples(params, collection_formats) List[Tuple[str, Any]]

Get parameters as list of tuples, formatting collections.

Parameters:
  • params – Parameters as dict or list of two-tuples

  • collection_formats (dict) – Parameter collection formats

Returns:

Parameters as list of tuples, collections formatted

classmethod sanitize_for_serialization(obj)

Prepares data for transmission before it is sent with the rest client. If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. If obj is io.IOBase, return the bytes.

Parameters:

obj – The data to serialize.

Returns:

The serialized form of data.

select_header_accept(accepts: List[str]) str

Returns Accept based on an array of accepts provided.

Parameters:

accepts – List of headers.

Returns:

Accept (e.g. application/json).

select_header_content_type(content_types: List[str]) str

Returns Content-Type based on an array of content_types provided.

Parameters:

content_types – List of content-types.

Returns:

Content-Type (e.g. application/json).

property user_agent: str

User agent for this API client

exception ApiException(status=None, reason=None, http_resp=None)

Bases: OpenApiException

exception ApiKeyError(msg, path_to_item=None)

Bases: OpenApiException, KeyError

Parameters:
  • msg (str) – The exception message.

  • path_to_item (list) – The path to the exception in the received_data dict. None if unset.

exception ApiTypeError(msg, path_to_item=None, valid_classes=None, key_type=None)

Bases: OpenApiException, TypeError

Raises an exception for TypeErrors.

Parameters:
  • msg (str) – The exception message.

  • path_to_item (list) – A list of keys an indices to get to the current_item None if unset.

  • valid_classes (tuple) – The primitive classes that current item should be an instance of None if unset.

  • key_type (bool) – False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list None if unset.

exception ApiValueError(msg, path_to_item=None)

Bases: OpenApiException, ValueError

Parameters:
  • msg (str) – The exception message.

  • path_to_item (list) – The path to the exception in the received_data dict. None if unset.

class AsyncApiClient(configuration: Configuration)

Bases: ApiClient

class Configuration(host=None, api_key=None, api_key_prefix=None, access_token=None, username=None, password=None, discard_unknown_keys=True, disabled_client_side_validations='', server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, ssl_ca_cert=None, compress=True, return_http_data_only=True, preload_content=True, request_timeout=None, check_input_type=True, check_return_type=True, spec_property_naming=False, enable_retry=False, retry_backoff_factor=2, max_retries=3)

Bases: object

Parameters:
  • host – Base url.

  • api_key – Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. The dict value is the API key secret.

  • api_key_prefix – Dict to store API prefix (e.g. Bearer). The dict key is the name of the security scheme in the OAS specification. The dict value is an API key prefix when generating the auth data.

  • username – Username for HTTP basic authentication.

  • password – Password for HTTP basic authentication.

  • discard_unknown_keys

    Boolean value indicating whether to discard unknown properties. A server may send a response that includes additional properties that are not known by the client in the following scenarios:

    1. The OpenAPI document is incomplete, i.e. it does not match the server implementation.

    2. The client was generated using an older version of the OpenAPI document and the server has been upgraded since then.

    If a schema in the OpenAPI document defines the additionalProperties attribute, then all undeclared properties received by the server are injected into the additional properties map. In that case, there are undeclared properties, and nothing to discard.

  • disabled_client_side_validations (str) – Comma-separated list of JSON schema validation keywords to disable JSON schema structural validation rules. The following keywords may be specified: multipleOf, maximum, exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, maxItems, minItems. By default, the validation is performed for data generated locally by the client and data received from the server, independent of any validation performed by the server side. If the input data does not satisfy the JSON schema validation rules specified in the OpenAPI document, an exception is raised. If disabled_client_side_validations is set, structural validation is disabled. This can be useful to troubleshoot data validation problem, such as when the OpenAPI document validation rules do not match the actual API data received by the server.

  • server_index – Index to servers configuration.

  • server_variables – Mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

  • server_operation_index – Mapping from operation ID to an index to server configuration.

  • server_operation_variables – Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

  • ssl_ca_cert – The path to a file of concatenated CA certificates in PEM format.

  • compress (bool) – Boolean indicating whether encoded responses are accepted or not.

  • return_http_data_only (bool) – Response data without head status code and headers. Default is True.

  • preload_content (bool) – If False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • request_timeout (float/tuple) – Timeout setting for this request. If one number is provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None.

  • check_input_type (bool) – Specifies if type checking should be done on the data sent to the server. Default is True.

  • check_return_type (bool) – Specifies if type checking should be done on the data received from the server. Default is True.

  • spec_property_naming (bool) – Whether names in properties are expected to respect the spec or use snake case.

  • enable_retry (bool) – If set, the client will retry requests on backend errors (5xx status codes), and 429. On 429 if will use the returned headers to wait until the next requests, otherwise it will retry using the backoff factor.

  • retry_backoff_factor (float) – Factor used to space out retried requests on backend errors.

  • max_retries (int) – The maximum number of times a single request can be retried.

Constructor.

auth_settings()

Gets Auth Settings dict for api client.

Returns:

The Auth Settings information dict.

property debug

Debug status.

Returns:

The debug status, True or False.

Return type:

bool

get_api_key_with_prefix(identifier, alias=None)

Gets API key (with prefix if set).

Parameters:
  • identifier – The identifier of apiKey.

  • alias – The alternative identifier of apiKey.

Returns:

The token for api key authentication.

get_basic_auth_token()

Gets HTTP basic authentication header (string).

Returns:

The token for basic HTTP authentication.

get_host_from_settings(index, variables=None, servers=None)

Gets host URL based on the index and variables.

Parameters:
  • index – Array index of the host settings.

  • variables – Hash of variable and the corresponding value.

  • servers – An array of host settings or None.

Returns:

URL based on host settings.

get_host_settings()

Gets an array of host settings

Returns:

An array of host settings

property host

Return generated host.

property logger_file

The logger file.

If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler.

Returns:

The logger_file path.

Return type:

str

property logger_format

The logger format.

The logger_formatter will be updated when sets logger_format.

Returns:

The format string.

Return type:

str

property retry_backoff_factor

Retry backoff factor.

Returns:

The backoff factor, float

Return type:

float

exception OpenApiException

Bases: Exception

The base exception class for all OpenAPIExceptions