API Base Class

class ApiEndpoint(api_obj, url)

Bases: object

This is the backbone of all API definitions. It performs all requests, validations, logging, re-authentication, and holds the raw response. This class MUST be inherited by all API definitions.

Parameters
  • api_obj – This is passed down from the API type object (eg. WebSDK, etc.) and represents that type. This type is REQUIRED because it contains the authenticated sessions, base URL, and re-authentication methods. It is through these properties this class is able to send and receive requests to TPP.

  • url (str) – This is the URL extension from the base URL.

property retries
ApiField(default=None, *, default_factory=None, alias=None, title=None, description=None, exclude=None, include=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, max_digits=None, decimal_places=None, min_items=None, max_items=None, unique_items=None, min_length=None, max_length=None, allow_mutation=True, regex=None, discriminator=None, repr=True, converter=None, **extra)
Parameters
  • default (Any) –

  • default_factory (Optional[NoArgAnyCallable]) –

  • alias (str) –

  • title (str) –

  • description (str) –

  • exclude (Union[AbstractSetIntStr, MappingIntStrAny, Any]) –

  • include (Union[AbstractSetIntStr, MappingIntStrAny, Any]) –

  • const (bool) –

  • gt (float) –

  • ge (float) –

  • lt (float) –

  • le (float) –

  • multiple_of (float) –

  • max_digits (int) –

  • decimal_places (int) –

  • min_items (int) –

  • max_items (int) –

  • unique_items (bool) –

  • min_length (int) –

  • max_length (int) –

  • allow_mutation (bool) –

  • regex (str) –

  • discriminator (str) –

  • repr (bool) –

  • converter (Callable[[Any], Any]) –

  • extra (Any) –

Return type

Any

class ApiModelMetaclass(name, bases, namespaces, **kwargs)

Bases: ModelMetaclass

class ApiSource(*args, **kwargs)

Bases: Protocol

re_authenticate()
exception InvalidResponseError(msg, response)

Bases: Exception

Parameters
  • msg (str) –

  • response (Response) –

pydantic model ObjectModel

Bases: BaseModel

pydantic model RootOutputModel

Bases: ObjectModel

field api_response: Union[Response, Any] = None
assert_valid_response()

Use this method when no response property is available after an API call or to simply throw an error if the return code is invalid. This simply asserts that a valid response status code was returned by TPP.

is_valid_response()

Returns True when the response is valid, meaning a valid return code was returned by TPP, otherwise False.

class WebSdkEndpoint(api_obj, url)

Bases: ApiEndpoint

Parameters
  • api_obj – This is passed down from the API type object (eg. WebSDK, etc.) and represents that type. This type is REQUIRED because it contains the authenticated sessions, base URL, and re-authentication methods. It is through these properties this class is able to send and receive requests to TPP.

  • url (str) – This is the URL extension from the base URL.

pydantic model WebSdkOutputModel

Bases: RootOutputModel

field api_response: Union[Response, Any] = None
field error: Union[str, Any] = None (alias 'Error')
generate_output(response, output_cls, root_field=None)
Parameters
  • response (Response) – Response instance returned by the requests call to the server.

  • output_cls (Type[T_]) – Custom APIResponse class.

  • root_field (Optional[str]) – In the case that the returned JSON is an array of objects, then the root_field is used to assign that value.

Returns

An instance of response_cls.

Return type

T_