Skip to content

class ServiceReader:

ServiceReader

Upon initialization ServiceReaders defines a dictionary called response_data. Caled operations are stored in this dictionary.

self.response_data data hierarchy
{
    "ResourceNodeName": {
        "OperationName1": [{response1 dict}, {response2 dict}, ...],
        "OperationName2": [{response1 dict},...],
    }
}

__init__(service_node)

Initializes the reader with the service_node.

Parameters:

Name Type Description Default
service_node ServiceNode

Associated ServiceNode.

required

add_to_node_data(resource_node_name, operation_name, response)

Adds boto3 api response to operations existing data.

Parameters:

Name Type Description Default
resource_node_name str

Name of the ResourceNode

required
operation_name str

Name of the Operation

required
response dict

boto API response dict

required

call_operation(resource_node, operation_name, api_parameter, follow_pagination=False)

Calls the given AWS operation with api_parameter dict. Saves the response data on self.response_data and returns it.

Parameters:

Name Type Description Default
resource_node ResourceNode

Operations Resource Node

required
operation_name str

Name of the operation

required
api_parameter dict

dictionary to call the operation with

required
follow_pagination Optional[bool]

If the operations output is truncated follow the pagination tokens.

False

Returns:

Type Description
Union[dict, bool]

Union[dict, bool]: False or response got from AWS API

clear_operations_data(resource_node_name, operation_name)

Refreshes the operations data to empty list.

Parameters:

Name Type Description Default
resource_node_name str

Name of the ResourceNode

required
operation_name str

Name of the Operation

required

read_operation(resource_node_name, operation_name, match_patterns=None, refresh=False, follow_pagination=False)

Reads the given operation. If the operation is called with generated parameters, match_patterns can be used to filter the generated parameters.

Parameters:

Name Type Description Default
resource_node_name str

Name of the Resource Node

required
operation_name str

Name of the Operation

required
match_patterns List[str]

UNIX style patterns to filter matching generated parameters. Defaults to None.

None
refresh bool

Get the cached data or force re-reading the operation. Defaults to False.

False
follow_pagination bool

Follow pagination tokens. If not only set True, one page call will be made.

False

Returns:

Type Description
Tuple[Union[List, bool], Union[Error, None]]

Tuple[Union[List, bool], Union[Error, None]]: description

read_resource_node(resource_node_name, match_patterns=None, refresh=False, follow_pagination=False)

Reads all available operations in the given a resource node

Parameters:

Name Type Description Default
resource_node_name str

description

required
match_patterns List[str]

UNIX style patterns to filter the generated parameters. Defaults to None.

None
refresh Optional[bool]

Use the cached data or always make new calls. Defaults to False.

False
follow_pagination Optional[bool]

Follow pagination if the output is truncated.. Defaults to False.

False

Returns:

Type Description
Union[Dict, bool]

Union[Dict, bool]: Data read if successful, or False.

search_operation_data(resource_node_name, operation_name)

Get the currently read and available operation data.

Parameters:

Name Type Description Default
resource_node_name str

Name of the ResourceNode

required
operation_name str

Name of the Operation

required

Returns:

Type Description
Union[List[dict], bool]

Union[List[dict], bool]: False or Operations data

search_resource_node_data(resource_node_name)

Gets all data available for the ResourceNode, including all of its operations.

Parameters:

Name Type Description Default
resource_node_name str

Name of the ResourceNode

required

Returns:

Type Description
Union[dict, bool]

Union[dict, bool]: False or all operations data of the given ResourceNode