Providers

Define an alternate way to retrieve the query responses.

Interface

class starmap_client.providers.StarmapProvider[source]

Define the interface for a local mappings provider.

api = 'default'

The provider’s API level implementation.

abstract query(params)[source]

Retrieve the mapping without using the server.

It relies in the local provider to retrieve the correct mapping according to the parameters.

Parameters:

params (dict) – The request params to retrieve the mapping.

Return type:

Optional[TypeVar(T, QueryResponse, QueryResponseContainer, QueryResponseEntity)]

Returns:

The requested mapping when found.

abstract list_content()[source]

Return a list with all stored responses.

Return type:

List[TypeVar(T, QueryResponse, QueryResponseContainer, QueryResponseEntity)]

abstract store(response)[source]

Store a single response into the local provider.

Parameters:

response (response) – The object to store.

Return type:

None

Implementations

Memory Based

APIv2

class starmap_client.providers.InMemoryMapProviderV2(container, *args, **kwargs)[source]

Provide in memory (RAM) QueryResponseContainer objects for APIv2.

__init__(container, *args, **kwargs)[source]

Crete a new InMemoryMapProvider object.

Parameters:

container (QueryResponseContainer) – QueryResponseContainer object to load into memory. It will be used by query to return the correct response based on name and workflow.

query(params)[source]

Retrieve the mapping without using the server.

It relies in the local provider to retrieve the correct mappings according to the parameters.

Parameters:

params (dict) – The request params to retrieve the mapping.

Return type:

Optional[QueryResponseContainer]

Returns:

The requested container with mappings when found.

list_content()[source]

Return a the responses stored in the container.

Return type:

List[QueryResponseEntity]

store(response)[source]

Store a single response into the local provider’s container.

Parameters:

container (container) – The container to store.

Return type:

None

APIv1 (deprecated)

class starmap_client.providers.InMemoryMapProviderV1(map_responses=None, *args, **kwargs)[source]

Provide in memory (RAM) QueryResponse mapping objects for APIv1.

__init__(map_responses=None, *args, **kwargs)[source]

Crete a new InMemoryMapProvider object.

Parameters:

map_responses (list, optional) – List of QueryResponse objects to load into memory. They will be used by query to fetch the correct response based on name and workflow.

list_content()[source]

Return a list of stored content.

Return type:

List[QueryResponse]

store(response)[source]

Store/replace a single QueryResponse object.

Parameters:

response (QueryResponse) – The object to store.

Return type:

None

query(params)[source]

Return the mapping from memory according to the received params.

Parameters:

params (dict) – The request params to retrieve the mapping.

Return type:

Optional[QueryResponse]

Returns:

The requested mapping when found.