google.cloud.forseti.services.utils module

Forseti Server utilities.

autoclose_stream(f)[source]

Decorator to close gRPC stream.

Parameters:f (func) – The function to decorate
Returns:wrapper of the decorator
Return type:wrapper
full_to_type_name(full_resource_name)[source]

Creates a type/name format from full resource name.

Parameters:full_resource_name (str) – the full_resource_name of the resource
Returns:type_name of that resource
Return type:str
get_resource_id_from_type_name(type_name)[source]

Returns the key from type_name.

Parameters:type_name (str) – Type name.
Returns:Resource id.
Return type:str
get_resources_from_full_name(full_name)[source]

Parse resource info from full name.

Parameters:full_name (str) – Full name of the resource in hierarchical format. Example of a full_name: organization/88888/project/myproject/firewall/99999/ full_name has a trailing / that needs to be removed.
Yields:iterator – strings of resource_type and resource_id
get_sql_dialect(session)[source]

Return the active SqlAlchemy dialect.

Parameters:session (object) – the session to check for SqlAlchemy dialect
Returns:name of the SqlAlchemy dialect
Return type:str
logcall(f, level=50)[source]

Call logging decorator.

Parameters:
  • f (func) – The function to decorate
  • level (str) – the level of logging
Returns:

wrapper of the decorator

Return type:

wrapper

mutual_exclusive(lock)[source]

Mutex decorator.

Parameters:lock (object) – The lock to lock out exclusive method
Returns:decorator generator
Return type:object
oneof(*args)[source]

Returns true iff one of the parameters is true.

Parameters:*args – arguments to check
Returns:true iff one of the parameters is true.
Return type:bool
resource_to_type_name(resource)[source]

Creates a type/name format from a resource dbo.

Parameters:resource (object) – the resource to get the the type_name
Returns:type_name of the resource
Return type:str
split_type_name(resource_type_name)[source]

Split the type name of the resource

Parameters:resource_type_name (str) – the type_name of the resource
Returns:type and name of the resource
Return type:tuples
to_full_resource_name(full_parent_name, resource_type_name)[source]

Creates a full resource name by parent full name and type name.

Parameters:
  • full_parent_name (str) – the full_resource_name of the parent
  • resource_type_name (str) – the full_resource_name of the child
Returns:

full_resource_name of the child

Return type:

str

to_type_name(resource_type, resource_name)[source]

Creates a type/name from type and name.

Parameters:
  • resource_type (str) – the resource type
  • resource_name (str) – the resource name
Returns:

type_name of the resource

Return type:

str