google.cloud.forseti.services.inventory.base.cloudasset module

Forseti Inventory Cloud Asset API integration.

_clear_cai_data(session)[source]

Clear CAI data from storage.

Parameters:session (object) – Database session.
_export_assets(cloudasset_client, config, root_id, content_type)[source]

Worker function for exporting assets and downloading dump from GCS.

Parameters:
  • cloudasset_client (CloudAssetClient) – CloudAsset API client interface.
  • config (object) – Inventory configuration on server.
  • root_id (str) – The name of the parent resource to export assests under.
  • content_type (ContentTypes) – The content type to export.
Returns:

The path to the temporary file downloaded from GCS or None on

error.

Return type:

str

_get_gcs_path(base_path, content_type, root_id, timestamp)[source]

Generate a GCS object path for CAI dump.

Parameters:
  • base_path (str) – The GCS bucket, starting with ‘gs://’.
  • content_type (str) – The Cloud Asset content type for this export.
  • root_id (str) – The root resource ID for this export.
  • timestamp (int) – The timestamp for this export.
Returns:

The full path to a GCS object to store export the data to.

Return type:

str

load_cloudasset_data(session, config)[source]

Export asset data from Cloud Asset API and load into storage.

Parameters:
  • session (object) – Database session.
  • config (object) – Inventory configuration on server.
Returns:

The count of assets imported into the database, or None if there

is an error.

Return type:

int