google.cloud.forseti.common.gcp_type.instance module

A Compute Instance.

See: https://cloud.google.com/compute/docs/reference/latest/instances

class Instance(instance_id, parent=None, **kwargs)[source]

Bases: google.cloud.forseti.common.gcp_type.resource.Resource

Represents Instance resource.

RESOURCE_NAME_FMT = 'instances/%s'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 208
_abc_registry = <_weakrefset.WeakSet object>
_create_json_str()[source]

Creates a json string based on the object attributes.

Returns:json str.
Return type:str
create_network_interfaces()[source]

Return a list of network_interface objects.

Returns:list of InstanceNetworkInterface objects
Return type:List
classmethod from_json(parent, json_string)[source]

Creates an Instance from an instance JSON string.

Parameters:
  • parent (Resource) – resource this instance belongs to. Should be a project.
  • json_string (str) – JSON string of a instance GCP API response.
Returns:

A new Instance object.

Return type:

Instance

json

Returns the json string representation of the resource.

Returns:json str.
Return type:str
key

Return a Key identifying the object.

Returns:the key
Return type:Key
class InstanceNetworkInterface(**kwargs)[source]

Bases: object

InstanceNetworkInterface Resource.

__eq__(other)[source]

Eq

Parameters:other (InstanceNetworkInterface) – other InstanceNetworkInterface
Returns:True if is equal
Return type:bool
__hash__()[source]

hash

Returns:of InstanceNetworkInterface
Return type:hash
__ne__(other)[source]

Ne

Parameters:other (InstanceNetworkInterface) – other InstanceNetworkInterface
Returns:True if not equal
Return type:bool
__repr__()[source]

Repr

Returns:a string for a InstanceNetworkInterface
Return type:string
as_json()[source]

Returns the attributes as json formatted string.

Returns:json formatted attribute of the instance network interface
Return type:string
class Key(object_kind, object_path)[source]

Bases: google.cloud.forseti.common.gcp_type.key.Key

An identifier for a specific instance.

static from_args(project_id, zone, name)[source]

Construct a Key from specific values.

Parameters:
  • project_id (str) – project_id
  • zone (str) – zone
  • name (str) – name
Returns:

the key

Return type:

Key

static from_url(url)[source]

Construct a Key from a URL.

Parameters:url (str) – Object reference URL
Returns:the key
Return type:Key
Raises:ValueError – Required parameters are missing.
name

Object property – name

Returns:name
Return type:str
project_id

Object property – project_id

Returns:project_id
Return type:str
zone

Object property – zone

Returns:zone
Return type:str