ask_sdk_model.services package

Subpackages

Submodules

Note

Canonical imports have been added in the __init__.py of the package. This helps in importing the class directly from the package, than through the module.

For eg: if package a has module b with class C, you can do from a import C instead of from a.b import C.

ask_sdk_model.services.api_client module

class ask_sdk_model.services.api_client.ApiClient

Bases: object

Represents a basic contract for API request invocation.

invoke(request)

Dispatches a request to an API endpoint described in the request.

The ApiClient is expected to resolve in the case an API returns a non-200 HTTP status code. The responsibility of translating a particular response code to an error lies with the caller.

Parameters:request (ApiClientRequest) – Request to dispatch to the ApiClient
Returns:Response from the client call
Return type:ApiClientResponse

ask_sdk_model.services.api_client_message module

class ask_sdk_model.services.api_client_message.ApiClientMessage(headers=None, body=None)

Bases: object

Represents the interface between ask_sdk_model.services.api_client.ApiClient implementation and a Service Client.

Parameters:
  • headers (list[tuple[str, str]]) – List of header tuples
  • body (str) – Body of the message

ask_sdk_model.services.api_client_request module

class ask_sdk_model.services.api_client_request.ApiClientRequest(headers=None, body=None, url=None, method=None)

Bases: ask_sdk_model.services.api_client_message.ApiClientMessage

Represents a request sent from Service Clients to an ask_sdk_model.services.api_client.ApiClient implementation.

Parameters:
  • headers (list[tuple[str, str]]) – List of header tuples
  • body (str) – Body of the message
  • url (str) – Url of the request
  • method (str) – Method called with the request

ask_sdk_model.services.api_client_response module

class ask_sdk_model.services.api_client_response.ApiClientResponse(headers=None, body=None, status_code=None)

Bases: ask_sdk_model.services.api_client_message.ApiClientMessage

Represents a response returned by ask_sdk_model.services.api_client.ApiClient implementation to a Service Client.

Parameters:
  • headers (list[tuple[str, str]]) – List of header tuples
  • body (str) – Body of the message
  • status_code (int) – Status code of the response

ask_sdk_model.services.api_configuration module

class ask_sdk_model.services.api_configuration.ApiConfiguration(serializer=None, api_client=None, authorization_value=None, api_endpoint=None)

Bases: object

Represents a class that provides API configuration options needed by service clients.

Parameters:

ask_sdk_model.services.api_response module

class ask_sdk_model.services.api_response.ApiResponse(headers=None, body=None, status_code=None)

Bases: object

Represents a response returned by the Service Client.

Parameters:
  • headers (list[tuple[str, str]]) – List of header tuples
  • body (object) – Body of the response
  • status_code (int) – Status code of the response

ask_sdk_model.services.authentication_configuration module

class ask_sdk_model.services.authentication_configuration.AuthenticationConfiguration(client_id=None, client_secret=None, refresh_token=None)

Bases: object

Represents a class that provides authentication configuration.

Parameters:
  • client_id (str) – Client ID required for authentication.
  • client_secret (str) – Client Secret required for authentication.
  • refresh_token (str) – Client refresh_token required to get access token for API calls.

ask_sdk_model.services.base_service_client module

class ask_sdk_model.services.base_service_client.BaseServiceClient(api_configuration)

Bases: object

Class to be used as the base class for the generated service clients.

The class has to be implemented by the service clients and this class instantiation is not supported

Parameters:api_configuration (ask_sdk_model.services.api_configuration.ApiConfiguration) – ApiConfiguration implementation
invoke(method, endpoint, path, query_params, header_params, path_params, response_definitions, body, response_type)

Calls the ApiClient based on the ServiceClient specific data provided as well as handles the well-known responses from the Api.

Parameters:
  • method (str) – Http method
  • endpoint – Base endpoint to make the request to
  • path (str) – Specific path to hit. It might contain variables to be interpolated with path_params
  • query_params (list(tuple(str, str))) – Parameter values to be sent as part of query string
  • header_params (list(tuple(str, str))) – Parameter values to be sent as headers
  • path_params (dict(str, str)) – Parameter values to be interpolated in the path
  • response_definitions (list(ask_sdk_model.services.service_client_response.ServiceClientResponse)) – Well-known expected responses by the ServiceClient
  • body (object) – Request body
  • response_type (class) – Type of the expected response if applicable
Returns:

ApiResponse object.

Return type:

ask_sdk_model.services.api_response.py

Raises:

ask_sdk_model.services.service_exception.ServiceException if service fails and ValueError if serializer or API Client is not configured in api_configuration # noqa: E501

ask_sdk_model.services.serializer module

class ask_sdk_model.services.serializer.Serializer

Bases: object

Represents an abstract object used for Serialization tasks

deserialize(payload, obj_type)

Deserializes the payload to object of provided obj_type.

Parameters:
  • payload (str) – String to deserialize
  • obj_type (object) – Target type of deserialization
Returns:

Deserialized object

Return type:

object

serialize(obj)

Serializes an object into a string.

Parameters:obj – object to serialize
Returns:serialized object in string format
Return type:str

ask_sdk_model.services.service_client_factory module

class ask_sdk_model.services.service_client_factory.ServiceClientFactory(api_configuration)

Bases: object

ServiceClientFactory class to help build service clients.

Parameters:api_configuration (ask_sdk_model.services.api_configuration.ApiConfiguration) – API Configuration for calling services
get_device_address_service()

Get DeviceAddressServiceClient for device_address_service.

Returns:Client for calling the service
Return type:DeviceAddressServiceClient
Raises:ValueError
get_directive_service()

Get DirectiveServiceClient for directive_service.

Returns:Client for calling the service
Return type:DirectiveServiceClient
Raises:ValueError
get_endpoint_enumeration_service()

Get EndpointEnumerationServiceClient for endpoint_enumeration_service.

Returns:Client for calling the service
Return type:EndpointEnumerationServiceClient
Raises:ValueError
get_list_management_service()

Get ListManagementServiceClient for list_management_service.

Returns:Client for calling the service
Return type:ListManagementServiceClient
Raises:ValueError
get_monetization_service()

Get MonetizationServiceClient for monetization_service.

Returns:Client for calling the service
Return type:MonetizationServiceClient
Raises:ValueError
get_reminder_management_service()

Get ReminderManagementServiceClient for reminder_management_service.

Returns:Client for calling the service
Return type:ReminderManagementServiceClient
Raises:ValueError
get_timer_management_service()

Get TimerManagementServiceClient for timer_management_service.

Returns:Client for calling the service
Return type:TimerManagementServiceClient
Raises:ValueError
get_ups_service()

Get UpsServiceClient for ups_service.

Returns:Client for calling the service
Return type:UpsServiceClient
Raises:ValueError

ask_sdk_model.services.service_client_response module

class ask_sdk_model.services.service_client_response.ServiceClientResponse(response_type, status_code, message)

Bases: object

Represents a well-known response object by Service Client.

Parameters:
  • response_type (Response class) – Well-known representation of the response
  • status_code (int) – Status code to be attached to the response
  • message (str) – Message to be attached to the response

ask_sdk_model.services.service_exception module

exception ask_sdk_model.services.service_exception.ServiceException(message, status_code, headers, body)

Bases: Exception

Exception thrown by a Service client when an error response was received or some operation failed.

Parameters:
  • message (str) – Description of the error
  • status_code (int) – Status code of the HTTP Response
  • headers (list(tuple(str, str))) – Headers of the Http response that return the failure
  • body (object) – Body of the HTTP Response