google.cloud.forseti.common.gcp_type.resource_util module

Util for generic operations for Resources.

create_resource(resource_id, resource_type, **kwargs)[source]

Factory to create a certain kind of Resource.

Parameters:
  • resource_id (str) – The resource id.
  • resource_type (str) – The resource type.
  • **kwargs (dict) – Extra args.
Returns:

The new Resource based on the type, if supported, otherwise None.

Return type:

Resource

create_resource_from_json(resource_type, parent, json_string)[source]

Factory to create a certain kind of Resource from JSON data.

Parameters:
  • resource_type (str) – The resource type.
  • parent (Resource) – parent resource of this type.
  • json_string (str) – resource’s JSON data.
Returns:

The new Resource based on the type, if supported, otherwise None.

Return type:

Resource

get_ancestors_from_full_name(full_name)[source]

Creates a Resource for each resource in the full ancestory path.

Parameters:full_name (str) – The full resource name from the model, includes all parent resources in the hierarchy to the root organization.
Returns:A list of Resource objects, from parent to base ancestor.
Return type:list
pluralize(resource_type)[source]

Determine the pluralized form of the resource type.

Parameters:resource_type (str) – The resource type for which to get its plural form.
Returns:The pluralized version of the resource type, if supported, otherwise None.
Return type:str
type_from_name(resource_name)[source]

Determine resource type from resource name.

Parameters:resource_name (str) – The unique resoure name, with the format “{resource_type}/{resource_id}”.
Returns:The resource type, if it exists, otherwise None.
Return type:str