Google Cloud Resource Manager API client library for managing projects, folders, organizations, and tags in Google Cloud Platform
npx @tessl/cli install tessl/pypi-google-cloud-resource-manager@1.14.0A comprehensive Python client library for the Google Cloud Resource Manager API, enabling developers to programmatically manage their Google Cloud Platform hierarchy. The library provides methods for creating, updating, and managing projects, folders, organizations, and tagging resources within the Google Cloud resource hierarchy, supporting both synchronous and asynchronous operations.
pip install google-cloud-resource-managerfrom google.cloud import resourcemanagerFor specific service clients:
from google.cloud.resourcemanager import (
ProjectsClient,
FoldersClient,
OrganizationsClient,
TagKeysClient,
TagValuesClient,
TagBindingsClient,
TagHoldsClient
)For async clients:
from google.cloud.resourcemanager import (
ProjectsAsyncClient,
FoldersAsyncClient,
OrganizationsAsyncClient,
TagKeysAsyncClient,
TagValuesAsyncClient,
TagBindingsAsyncClient,
TagHoldsAsyncClient
)from google.cloud.resourcemanager import ProjectsClient
# Initialize the client (uses default credentials)
client = ProjectsClient()
# Get a project
project = client.get_project(name="projects/my-project-id")
print(f"Project: {project.display_name}")
# List projects under an organization
for project in client.list_projects(parent="organizations/123456789"):
print(f"Project: {project.project_id} - {project.display_name}")
# Create a new project
from google.cloud.resourcemanager_v3.types import Project
new_project = Project(
project_id="my-new-project",
display_name="My New Project",
parent="organizations/123456789"
)
operation = client.create_project(project=new_project)
result = operation.result() # Wait for completion
print(f"Created project: {result.project_id}")The Google Cloud Resource Manager API is organized around a hierarchical resource structure and tagging system:
Each resource type has dedicated synchronous and asynchronous client classes with consistent patterns:
Comprehensive project lifecycle management including creation, updates, hierarchy management, and deletion/restoration. Projects serve as the fundamental organizational unit for Google Cloud resources.
class ProjectsClient:
def get_project(
self,
request: GetProjectRequest = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> Project: ...
def list_projects(
self,
request: ListProjectsRequest = None,
*,
parent: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.ListProjectsPager: ...
def create_project(
self,
request: CreateProjectRequest = None,
*,
project: Project = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...Hierarchical organization and management of folders within organizations, providing an intermediate grouping layer between organizations and projects.
class FoldersClient:
def get_folder(
self,
request: GetFolderRequest = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> Folder: ...
def create_folder(
self,
request: CreateFolderRequest = None,
*,
folder: Folder = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...Read-only access to organization information and search capabilities. Organizations represent the root-level container in the Google Cloud resource hierarchy.
class OrganizationsClient:
def get_organization(
self,
request: GetOrganizationRequest = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> Organization: ...
def search_organizations(
self,
request: SearchOrganizationsRequest = None,
*,
query: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.SearchOrganizationsPager: ...Management of tag categories that define the taxonomy for organizing and controlling Google Cloud resources through policy and automation.
class TagKeysClient:
def get_tag_key(
self,
request: GetTagKeyRequest = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> TagKey: ...
def create_tag_key(
self,
request: CreateTagKeyRequest = None,
*,
tag_key: TagKey = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...Management of specific values within tag categories, providing the actual tags that can be applied to Google Cloud resources.
class TagValuesClient:
def get_tag_value(
self,
request: GetTagValueRequest = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> TagValue: ...
def create_tag_value(
self,
request: CreateTagValueRequest = None,
*,
tag_value: TagValue = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...Association and management of tag values with specific Google Cloud resources, including listing effective tags that apply to resources through inheritance.
class TagBindingsClient:
def create_tag_binding(
self,
request: CreateTagBindingRequest = None,
*,
tag_binding: TagBinding = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...
def list_effective_tags(
self,
request: ListEffectiveTagsRequest = None,
*,
parent: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.ListEffectiveTagsPager: ...Protection mechanism for tag values by creating holds that prevent deletion, ensuring critical tags remain available for policy enforcement and resource organization.
class TagHoldsClient:
def create_tag_hold(
self,
request: CreateTagHoldRequest = None,
*,
parent: str = None,
tag_hold: TagHold = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation: ...
def list_tag_holds(
self,
request: ListTagHoldsRequest = None,
*,
parent: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.ListTagHoldsPager: ...# Core resource types
class Project:
name: str
project_id: str
display_name: str
parent: str
state: Project.State
labels: MutableMapping[str, str]
create_time: timestamp_pb2.Timestamp
update_time: timestamp_pb2.Timestamp
delete_time: timestamp_pb2.Timestamp
etag: str
class Folder:
name: str
parent: str
display_name: str
state: Folder.State
create_time: timestamp_pb2.Timestamp
update_time: timestamp_pb2.Timestamp
delete_time: timestamp_pb2.Timestamp
etag: str
class Organization:
name: str
display_name: str
directory_customer_id: str
state: Organization.State
create_time: timestamp_pb2.Timestamp
update_time: timestamp_pb2.Timestamp
delete_time: timestamp_pb2.Timestamp
etag: str
# Tag-related types
class TagKey:
name: str
parent: str
short_name: str
namespaced_name: str
display_name: str
description: str
purpose: Purpose
purpose_data: MutableMapping[str, str]
create_time: timestamp_pb2.Timestamp
update_time: timestamp_pb2.Timestamp
etag: str
class TagValue:
name: str
parent: str
short_name: str
namespaced_name: str
display_name: str
description: str
create_time: timestamp_pb2.Timestamp
update_time: timestamp_pb2.Timestamp
etag: str
class TagBinding:
name: str
parent: str
tag_value: str
tag_value_namespaced_name: str
class TagHold:
name: str
holder: str
origin: str
help_link: str
create_time: timestamp_pb2.Timestamp
# Long-running operation type
from google.api_core.operation import Operation