Implementation

class starmap_client.StarmapClient(url=None, api_version='v2', session=None, session_params=None, provider=None)[source]

Implement the StArMap client.

POLICIES_PER_PAGE = 100

Number of policies to retrieve per call.

__init__(url=None, api_version='v2', session=None, session_params=None, provider=None)[source]

Create a new StArMapClient.

Parameters:
  • url (str, optional) – URL of the StArMap endpoint. Required when session is not set.

  • api_version (str, optional) – The StArMap API version. Defaults to v2.

  • session (StarmapBaseSession, optional) – Defines the session object to use. Defaults to StarmapSession when not set

  • session_params (dict, optional) – Additional keyword arguments for StarmapSession

  • provider (StarmapProvider, optional) – Object responsible to provide mappings locally. When set the client will be query it first and if no mapping is found the subsequent request will be made to the server.

query_image(nvr, **kwargs)[source]

Query StArMap using an image NVR.

Parameters:
  • nvr (str) – The image archive name or NVR.

  • workflow (Workflow, optional) – The desired workflow to retrieve the mappings (APIv1 Only)

Returns:

The query result when found or None.

Return type:

Q

query_image_by_name(name, version=None, **kwargs)[source]

Query StArMap using an image NVR.

Parameters:
  • name (str) – The image name from NVR.

  • version (str, optional) – The version from NVR.

  • workflow (Workflow, optional) – The desired workflow to retrieve the mappings (APIv1 Only)

Returns:

The query result when found or None.

Return type:

Q

property policies: Iterator[Policy]

Iterate over all Policies registered in StArMap.

list_policies()[source]

List all Policies present in StArMap.

Returns:

List with all policies present in StArMap.

Return type:

list(Policy)

get_policy(policy_id)[source]

Retrieve a single policy by its ID.

Parameters:

policy_id (str) – The Policy ID to retrieve from StArMap.

Returns:

The requested Policy when found.

Return type:

Policy

list_mappings(policy_id)[source]

List all mappings for a given Policy ID.

Parameters:

policy_id (str) – Policy ID to list the mappings.

Return type:

List[Mapping]

Returns:

List with the Mappings for the requested Policy.

get_mapping(mapping_id)[source]

Retrieve a single Marketplace Mapping by its ID.

Parameters:

mapping_id (str) – The Markeplace Mapping ID to retrieve from StArmAp.

Return type:

Optional[Mapping]

Returns:

The requested Marketplace Mapping when found.

list_destinations(mapping_id)[source]

List all destinations for a given Marketplace Mapping ID.

Parameters:

mapping_id (str) – Marketplace Mapping ID to list the mappings.

Return type:

List[Destination]

Returns:

List with the Destinations for the requested Mapping.

get_destination(destination_id)[source]

Retrieve a single Destination by its ID.

Parameters:

destination_id (str) – The Destination ID to retrieve from StArmAp.

Return type:

Optional[Destination]

Returns:

The requested Destination when found.