google.cloud.forseti.common.gcp_api.servicemanagement module

Wrapper for Service Management API client.

class ServiceManagementClient(global_configs, **kwargs)[source]

Bases: object

Service Management Client.

DEFAULT_MAX_RESULTS = 100
get_all_apis()[source]

Gets all APIs that can be enabled (based on caller’s permissions).

Returns:A list of ManagedService resource dicts. https://cloud.google.com/service-management/reference/rest/v1/services#ManagedService
{
“serviceName”: string, “producerProjectId”: string,

}

Return type:list
Raises:ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails.
get_api_iam_policy(service_name)[source]

Gets the IAM policy associated with a service.

NOTE: This does not include IAM policy inherited from a service’s producer project. (I.e. project-level IAM Policy may grant service-level permissions that do not appear in a service’s IAM Policy.)

Parameters:service_name (str) – The service name to query.
Returns:A single Policy resource dict. https://cloud.google.com/service-infrastructure/docs/service-management/reference/rest/v1/Policy
{
“version”: string, “bindings”: list(Binding), “auditConfigs”: list(AuditConfig), “etag”: string,

}

Return type:dict
Raises:ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails.
get_enabled_apis(project_id)[source]

Gets the enabled APIs for a project.

Parameters:project_id (str) – The project id for a GCP project.
Returns:A list of ManagedService resource dicts. https://cloud.google.com/service-management/reference/rest/v1/services#ManagedService
{
“serviceName”: string, “producerProjectId”: string,

}

Return type:list
Raises:ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails.
get_produced_apis(project_id)[source]

Gets the APIs produced by a project.

Parameters:project_id (str) – The project id for a GCP project.
Returns:A list of ManagedService resource dicts. https://cloud.google.com/service-management/reference/rest/v1/services#ManagedService
{
“serviceName”: string, “producerProjectId”: string,

}

Return type:list
Raises:ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails.
class ServiceManagementRepositoryClient(quota_max_calls=None, quota_period=100.0, use_rate_limiter=True)[source]

Bases: google.cloud.forseti.common.gcp_api._base_repository.BaseRepositoryClient

Service Management API Respository.

services

Returns a _ServiceManagementServicesRepository instance.

class _ServiceManagementServicesRepository(**kwargs)[source]

Bases: google.cloud.forseti.common.gcp_api.repository_mixins.GetIamPolicyQueryMixin, google.cloud.forseti.common.gcp_api.repository_mixins.ListQueryMixin, google.cloud.forseti.common.gcp_api._base_repository.GCPRepository

Implementation of Service Management Services repository.

NOTE: unlike the list() API used for other GCP resources, the services.list() API does not accept a singular ‘resource’. Instead, two optional arguments allow specification of either the producer (parent) project (which results in a list of its child services), or the consumer project (which results in a list of services enabled on that project). If neither is specified, services.list() returns all visible services (where visibility is based on the provided credentials).

static get_formatted_project_name(project_id)[source]

Returns a formatted project_id string, required for some api args.

Parameters:project_id (str) – The project id to query, either just the id or the id prefixed with ‘projects/’.
Returns:The formatted project id.
Return type:str
static get_formatted_service_name(service_name)[source]

Returns a formatted service_name string, required for some api args.

Parameters:service_name (str) – The name of the service to query.
Returns:The formatted service name.
Return type:str