google.cloud.forseti.common.gcp_api.container module

Wrapper for SQL API client.

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

Bases: object

Cloud Kubernetes Engine Client.

get_clusters(project_id, zone='-')[source]

Gets the clusters and their node pools for a project and zone.

If zone is not specified, it lists clusters for all zones in the project.

Parameters:
  • project_id (int) – The project id for a GCP project.
  • zone (str) – Name of the zone to get the configuration for. Use ‘-‘ to return clusters from all zones.
Returns:

A list of Cluster dicts. https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.zones.clusters#Cluster

Return type:

list

An example return value:

[
{“name”: “cluster-1”, …} {“name”: “cluster-2”, …}, {…}

]

Raises:ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails
get_serverconfig(project_id, zone=None, location=None)[source]

Gets the serverconfig for a project and zone or location.

Requires either a zone or a location, if both are passed in, the location is used instead of the zone.

Parameters:
  • project_id (int) – The project id for a GCP project.
  • zone (str) – Name of the zone to get the configuration for.
  • location (str) – Name of the location to get the configuration for.
Returns:

A serverconfig for a given Compute Engine zone. https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/ServerConfig

Return type:

dict

An example return value:

{

“defaultClusterVersion”: string, “validNodeVersions”: [

string

], “defaultImageType”: string, “validImageTypes”: [

string

], “validMasterVersions”: [

string

],

}

Raises:
  • ApiExecutionError – ApiExecutionError is raised if the call to the GCP API fails
  • ValueError – Raised if neither zone nor location are passed in.
class ContainerRepositoryClient(quota_max_calls=None, quota_period=100.0, use_rate_limiter=True)[source]

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

Cloud Kubernetes Engine API Respository.

projects_locations

Returns a _ContainerProjectsLocationsRepository instance.

projects_zones

Returns a _ContainerProjectsZonesRepository instance.

projects_zones_clusters

Returns a _ContainerProjectsZonesClustersRepository instance.

class _ContainerProjectsLocationsRepository(**kwargs)[source]

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

Implementation of Container Projects.Locations repository.

get_serverconfig(project_id, location, fields=None, **kwargs)[source]

Get KE serverconfig for location.

Parameters:
  • project_id (str) – The id of the project to query.
  • location (str) – Name of the location to get the configuration for.
  • fields (str) – Fields to include in the response - partial response.
  • **kwargs (dict) – Optional additional arguments to pass to the query.
Returns:

Response from the API.

Return type:

dict

Raises:

errors.HttpError – When attempting to get a non-existent entity. ex: HttpError 404 when requesting … returned

“The resource ‘…’ was not found”

class _ContainerProjectsZonesClustersRepository(**kwargs)[source]

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

Implementation of Container Projects.Zones.Clusters repository.

class _ContainerProjectsZonesRepository(**kwargs)[source]

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

Implementation of Container Projects.Zones repository.

get_serverconfig(project_id, zone, fields=None, **kwargs)[source]

Get KE serverconfig for zone.

Parameters:
  • project_id (str) – The id of the project to query.
  • zone (str) – Name of the zone to get the configuration for.
  • fields (str) – Fields to include in the response - partial response.
  • **kwargs (dict) – Optional additional arguments to pass to the query.
Returns:

Response from the API.

Return type:

dict

Raises:

errors.HttpError – When attempting to get a non-existent entity. ex: HttpError 404 when requesting … returned

“The resource ‘…’ was not found”