google.cloud.forseti.notifier.notifiers.inventory_summary module

Upload inventory summary to GCS.

class InventorySummary(service_config, inventory_index_id)[source]

Bases: object

Create and send inventory summary.

_get_details_data()[source]

Get the detailed summarized inventory data.

Returns:
Summary details of sorted inventory data as a list of dicts.
Example: [{resource_type, count}, {}, {}, …]
Return type:list
Raises:NoDataError – If summary details data is not found.
_get_output_filename(filename_template)[source]

Create the output filename.

Parameters:filename_template (string) – template to use for the output filename
Returns:The output filename for the inventory summary file.
Return type:str
_get_summary_data()[source]

Get the summarized inventory data.

Returns:
Summary of sorted inventory data as a list of dicts.
Example: [{resource_type, count}, {}, {}, …]
Return type:list
Raises:NoDataError – If summary data is not found.
_send_email(summary_data, details_data)[source]

Send the email for inventory summary.

Parameters:
  • summary_data (list) – Summary of inventory data as a list of dicts. Example: [{resource_type, count}, {}, {}, …]
  • details_data (list) – Details of inventory data as a list of dicts. Example: [[{resource_type, count}, {}, {}, …]
_upload_to_gcs(summary_data)[source]

Upload inventory summary to GCS.

Parameters:summary_data (list) – Summary of inventory data as a list of dicts. Example: [{resource_type, count}, {}, {}, …]
run()[source]

Generate inventory summary.

static transform_to_template(data)[source]

Helper method to return sorted list of dicts.

Parameters:data (dict) – dictionary of resource_type: count pairs.
Returns:
Sorted data as a list of dicts.
Example: [{resource_type, count}, {}, {}, …]
Return type:list