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
)]
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:
- Returns:
The requested container with mappings when found.
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.
- store(response)[source]¶
Store/replace a single QueryResponse object.
- Parameters:
response (QueryResponse) – The object to store.
- Return type: