google.cloud.forseti.services.base.config module

Base classes required for handling configuration of the gRPC server.

class AbstractInventoryConfig[source]

Bases: object

Abstract base class for service configuration.

This class is used to implement dependency injection for the gRPC services.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 207
_abc_registry = <_weakrefset.WeakSet object>
get_api_quota_configs()[source]

Returns the per API quota configs.

get_cai_asset_types()[source]

Returns the GCS bucket path to store the CAI data dumps in.

get_cai_enabled()[source]

Returns True if the cloudasset API should be used.

get_cai_gcs_path()[source]

Returns the GCS bucket path to store the CAI data dumps in.

get_cai_timeout()[source]

Returns the timeout in seconds for calls to the Cloud Asset API.

get_composite_root_resources()[source]

Returns the composite root resource ids.

get_gsuite_admin_email()[source]

Returns gsuite admin email.

get_retention_days_configs()[source]

Returns the days of inventory data to retain.

get_root_resource_id()[source]

Returns the root resource id.

get_service_config()[source]

Returns the service config.

set_service_config(service_config)[source]

Attach a service configuration.

Parameters:service_config (object) – Service configuration.
use_composite_root()[source]

Checks if inventory is configured to use a composite root resource.

class AbstractServiceConfig[source]

Bases: object

Abstract base class for service configuration.

This class is used to implement dependency injection for the gRPC services.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 207
_abc_registry = <_weakrefset.WeakSet object>
client()[source]

Get an API client.

get_engine()[source]

Get the database engine.

get_storage_class()[source]

Returns the class used for the inventory storage.

run_in_background(func)[source]

Runs a function in a thread pool in the background.

Parameters:func (Function) – Function to be executed.
scoped_session()[source]

Get a scoped session.

class InventoryConfig(root_resource_id, gsuite_admin_email, api_quota_configs, retention_days, cai_configs, composite_root_resources=None)[source]

Bases: google.cloud.forseti.services.base.config.AbstractInventoryConfig

Implements composed dependency injection for the inventory.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 207
_abc_registry = <_weakrefset.WeakSet object>
get_api_quota_configs()[source]

Returns the per API quota configs.

Returns:The API quota configurations.
Return type:dict
get_cai_asset_types()[source]

Returns the list of Asset Types to include in the CAI export.

The full list of supported asset types is at: https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview

Returns:
The list of asset types to include, or None if all asset
types should be included.
Return type:list
get_cai_enabled()[source]

Returns True if the cloudasset API should be used for the inventory.

Returns:Whether CAI should be integrated with the inventory or not.
Return type:bool
get_cai_gcs_path()[source]

Returns the GCS bucket path to store the CAI data dumps in.

Returns:The GCS bucket path for CAI data.
Return type:str
get_cai_timeout()[source]

Returns the timeout in seconds for calls to the Cloud Asset API.

Returns:Timeout in seconds, defaults to 3600 seconds.
Return type:int
get_composite_root_resources()[source]

Returns the composite root resource ids.

Returns:
The list of root resources defined in the configuration or
None.
Return type:list
get_gsuite_admin_email()[source]

Return the gsuite admin email to use.

Returns:Gsuite admin email.
Return type:str
get_retention_days_configs()[source]

Returns the days of inventory data to retain.

Returns:The days of inventory data to retain.
Return type:int
get_root_resource_id()[source]

Return the configured root resource id.

Returns:Root resource id if defined, else None.
Return type:str
get_service_config()[source]

Return the attached service configuration.

Returns:Service configuration.
Return type:object
set_service_config(service_config)[source]

Attach a service configuration.

Parameters:service_config (object) – Service configuration.
use_composite_root()[source]

Checks if inventory is configured to use a composite root resource.

Returns:True if using a composite root, else False.
Return type:bool
class ServiceConfig(forseti_config_file_path, forseti_db_connect_string, endpoint)[source]

Bases: google.cloud.forseti.services.base.config.AbstractServiceConfig

Implements composed dependency injection to Forseti Server services.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 207
_abc_registry = <_weakrefset.WeakSet object>
_read_from_config(config_file_path=None)[source]

Read from the forseti configuration file.

Parameters:config_file_path (str) – Forseti server config file path
Returns:(Forseti server configuration, Error message)
Return type:tuple(dict, str)
client()[source]

Get an API client.

Returns:API client to use against services.
Return type:object
get_engine()[source]

Get the database engine.

Returns:Database engine object.
Return type:object
get_forseti_config()[source]

Get the Forseti config.

Returns:Forseti config.
Return type:dict
get_global_config()[source]

Get the global config.

Returns:Global config.
Return type:dict
get_inventory_config()[source]

Get the inventory config.

Returns:Inventory config.
Return type:object
get_notifier_config()[source]

Get the notifier config.

Returns:Notifier config.
Return type:dict
get_scanner_config()[source]

Get the scanner config.

Returns:Scanner config.
Return type:dict
get_storage_class()[source]

Returns the storage class used to access the inventory.

Returns:Type of a storage implementation.
Return type:class
run_in_background(func)[source]

Runs a function in a thread pool in the background.

Parameters:func (Function) – Function to be executed.
scoped_session()[source]

Get a scoped session.

Returns:A scoped session.
Return type:object
update_configuration(config_file_path=None)[source]

Update the inventory, scanner, global and notifier configurations.

Parameters:config_file_path (str) – Forseti server config file path.
Returns:(Configuration was updated, Error message)
Return type:tuple(bool, str)
_validate_cai_enabled(cai_configs)[source]

Verifies if CloudAsset Inventory can be used for this inventory config.

Parameters:cai_configs (dict) – Settings for the Cloud AssetInventory API
Returns:True if CAI is supported and enabled by configuration, else False.
Return type:bool