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.00
# Google Cloud Resource Manager
1
2
A 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.
3
4
## Package Information
5
6
- **Package Name**: google-cloud-resource-manager
7
- **Language**: Python
8
- **Installation**: `pip install google-cloud-resource-manager`
9
- **Supported Python Versions**: 3.7+
10
11
## Core Imports
12
13
```python
14
from google.cloud import resourcemanager
15
```
16
17
For specific service clients:
18
19
```python
20
from google.cloud.resourcemanager import (
21
ProjectsClient,
22
FoldersClient,
23
OrganizationsClient,
24
TagKeysClient,
25
TagValuesClient,
26
TagBindingsClient,
27
TagHoldsClient
28
)
29
```
30
31
For async clients:
32
33
```python
34
from google.cloud.resourcemanager import (
35
ProjectsAsyncClient,
36
FoldersAsyncClient,
37
OrganizationsAsyncClient,
38
TagKeysAsyncClient,
39
TagValuesAsyncClient,
40
TagBindingsAsyncClient,
41
TagHoldsAsyncClient
42
)
43
```
44
45
## Basic Usage
46
47
```python
48
from google.cloud.resourcemanager import ProjectsClient
49
50
# Initialize the client (uses default credentials)
51
client = ProjectsClient()
52
53
# Get a project
54
project = client.get_project(name="projects/my-project-id")
55
print(f"Project: {project.display_name}")
56
57
# List projects under an organization
58
for project in client.list_projects(parent="organizations/123456789"):
59
print(f"Project: {project.project_id} - {project.display_name}")
60
61
# Create a new project
62
from google.cloud.resourcemanager_v3.types import Project
63
64
new_project = Project(
65
project_id="my-new-project",
66
display_name="My New Project",
67
parent="organizations/123456789"
68
)
69
70
operation = client.create_project(project=new_project)
71
result = operation.result() # Wait for completion
72
print(f"Created project: {result.project_id}")
73
```
74
75
## Architecture
76
77
The Google Cloud Resource Manager API is organized around a hierarchical resource structure and tagging system:
78
79
### Resource Hierarchy
80
- **Organizations**: Root-level container for all Google Cloud resources
81
- **Folders**: Intermediate grouping mechanism within organizations
82
- **Projects**: Fundamental organizational unit containing Google Cloud resources
83
84
### Tagging System
85
- **TagKeys**: Define tag categories (e.g., "environment", "team")
86
- **TagValues**: Define specific values within tag categories (e.g., "production", "development")
87
- **TagBindings**: Associate TagValues with specific cloud resources
88
- **TagHolds**: Prevent TagValue deletion by creating dependencies
89
90
### Client Design
91
Each resource type has dedicated synchronous and asynchronous client classes with consistent patterns:
92
- CRUD operations (Create, Read, Update, Delete)
93
- Long-running operations for create/update/delete/move operations
94
- IAM policy management
95
- Pagination support for list operations
96
- Search functionality where applicable
97
98
## Capabilities
99
100
### Projects Management
101
102
Comprehensive project lifecycle management including creation, updates, hierarchy management, and deletion/restoration. Projects serve as the fundamental organizational unit for Google Cloud resources.
103
104
```python { .api }
105
class ProjectsClient:
106
def get_project(
107
self,
108
request: GetProjectRequest = None,
109
*,
110
name: str = None,
111
retry: OptionalRetry = gapic_v1.method.DEFAULT,
112
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
113
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
114
) -> Project: ...
115
116
def list_projects(
117
self,
118
request: ListProjectsRequest = None,
119
*,
120
parent: str = None,
121
retry: OptionalRetry = gapic_v1.method.DEFAULT,
122
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
123
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
124
) -> pagers.ListProjectsPager: ...
125
126
def create_project(
127
self,
128
request: CreateProjectRequest = None,
129
*,
130
project: Project = None,
131
retry: OptionalRetry = gapic_v1.method.DEFAULT,
132
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
133
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
134
) -> operation.Operation: ...
135
```
136
137
[Projects Management](./projects.md)
138
139
### Folders Management
140
141
Hierarchical organization and management of folders within organizations, providing an intermediate grouping layer between organizations and projects.
142
143
```python { .api }
144
class FoldersClient:
145
def get_folder(
146
self,
147
request: GetFolderRequest = None,
148
*,
149
name: str = None,
150
retry: OptionalRetry = gapic_v1.method.DEFAULT,
151
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
152
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
153
) -> Folder: ...
154
155
def create_folder(
156
self,
157
request: CreateFolderRequest = None,
158
*,
159
folder: Folder = None,
160
retry: OptionalRetry = gapic_v1.method.DEFAULT,
161
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
162
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
163
) -> operation.Operation: ...
164
```
165
166
[Folders Management](./folders.md)
167
168
### Organizations Management
169
170
Read-only access to organization information and search capabilities. Organizations represent the root-level container in the Google Cloud resource hierarchy.
171
172
```python { .api }
173
class OrganizationsClient:
174
def get_organization(
175
self,
176
request: GetOrganizationRequest = None,
177
*,
178
name: str = None,
179
retry: OptionalRetry = gapic_v1.method.DEFAULT,
180
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
181
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
182
) -> Organization: ...
183
184
def search_organizations(
185
self,
186
request: SearchOrganizationsRequest = None,
187
*,
188
query: str = None,
189
retry: OptionalRetry = gapic_v1.method.DEFAULT,
190
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
191
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
192
) -> pagers.SearchOrganizationsPager: ...
193
```
194
195
[Organizations Management](./organizations.md)
196
197
### Tag Keys Management
198
199
Management of tag categories that define the taxonomy for organizing and controlling Google Cloud resources through policy and automation.
200
201
```python { .api }
202
class TagKeysClient:
203
def get_tag_key(
204
self,
205
request: GetTagKeyRequest = None,
206
*,
207
name: str = None,
208
retry: OptionalRetry = gapic_v1.method.DEFAULT,
209
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
210
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
211
) -> TagKey: ...
212
213
def create_tag_key(
214
self,
215
request: CreateTagKeyRequest = None,
216
*,
217
tag_key: TagKey = None,
218
retry: OptionalRetry = gapic_v1.method.DEFAULT,
219
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
220
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
221
) -> operation.Operation: ...
222
```
223
224
[Tag Keys Management](./tag-keys.md)
225
226
### Tag Values Management
227
228
Management of specific values within tag categories, providing the actual tags that can be applied to Google Cloud resources.
229
230
```python { .api }
231
class TagValuesClient:
232
def get_tag_value(
233
self,
234
request: GetTagValueRequest = None,
235
*,
236
name: str = None,
237
retry: OptionalRetry = gapic_v1.method.DEFAULT,
238
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
239
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
240
) -> TagValue: ...
241
242
def create_tag_value(
243
self,
244
request: CreateTagValueRequest = None,
245
*,
246
tag_value: TagValue = None,
247
retry: OptionalRetry = gapic_v1.method.DEFAULT,
248
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
249
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
250
) -> operation.Operation: ...
251
```
252
253
[Tag Values Management](./tag-values.md)
254
255
### Tag Bindings Management
256
257
Association and management of tag values with specific Google Cloud resources, including listing effective tags that apply to resources through inheritance.
258
259
```python { .api }
260
class TagBindingsClient:
261
def create_tag_binding(
262
self,
263
request: CreateTagBindingRequest = None,
264
*,
265
tag_binding: TagBinding = None,
266
retry: OptionalRetry = gapic_v1.method.DEFAULT,
267
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
268
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
269
) -> operation.Operation: ...
270
271
def list_effective_tags(
272
self,
273
request: ListEffectiveTagsRequest = None,
274
*,
275
parent: str = None,
276
retry: OptionalRetry = gapic_v1.method.DEFAULT,
277
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
278
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
279
) -> pagers.ListEffectiveTagsPager: ...
280
```
281
282
[Tag Bindings Management](./tag-bindings.md)
283
284
### Tag Holds Management
285
286
Protection mechanism for tag values by creating holds that prevent deletion, ensuring critical tags remain available for policy enforcement and resource organization.
287
288
```python { .api }
289
class TagHoldsClient:
290
def create_tag_hold(
291
self,
292
request: CreateTagHoldRequest = None,
293
*,
294
parent: str = None,
295
tag_hold: TagHold = None,
296
retry: OptionalRetry = gapic_v1.method.DEFAULT,
297
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
298
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
299
) -> operation.Operation: ...
300
301
def list_tag_holds(
302
self,
303
request: ListTagHoldsRequest = None,
304
*,
305
parent: str = None,
306
retry: OptionalRetry = gapic_v1.method.DEFAULT,
307
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
308
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
309
) -> pagers.ListTagHoldsPager: ...
310
```
311
312
[Tag Holds Management](./tag-holds.md)
313
314
## Common Types
315
316
```python { .api }
317
# Core resource types
318
class Project:
319
name: str
320
project_id: str
321
display_name: str
322
parent: str
323
state: Project.State
324
labels: MutableMapping[str, str]
325
create_time: timestamp_pb2.Timestamp
326
update_time: timestamp_pb2.Timestamp
327
delete_time: timestamp_pb2.Timestamp
328
etag: str
329
330
class Folder:
331
name: str
332
parent: str
333
display_name: str
334
state: Folder.State
335
create_time: timestamp_pb2.Timestamp
336
update_time: timestamp_pb2.Timestamp
337
delete_time: timestamp_pb2.Timestamp
338
etag: str
339
340
class Organization:
341
name: str
342
display_name: str
343
directory_customer_id: str
344
state: Organization.State
345
create_time: timestamp_pb2.Timestamp
346
update_time: timestamp_pb2.Timestamp
347
delete_time: timestamp_pb2.Timestamp
348
etag: str
349
350
# Tag-related types
351
class TagKey:
352
name: str
353
parent: str
354
short_name: str
355
namespaced_name: str
356
display_name: str
357
description: str
358
purpose: Purpose
359
purpose_data: MutableMapping[str, str]
360
create_time: timestamp_pb2.Timestamp
361
update_time: timestamp_pb2.Timestamp
362
etag: str
363
364
class TagValue:
365
name: str
366
parent: str
367
short_name: str
368
namespaced_name: str
369
display_name: str
370
description: str
371
create_time: timestamp_pb2.Timestamp
372
update_time: timestamp_pb2.Timestamp
373
etag: str
374
375
class TagBinding:
376
name: str
377
parent: str
378
tag_value: str
379
tag_value_namespaced_name: str
380
381
class TagHold:
382
name: str
383
holder: str
384
origin: str
385
help_link: str
386
create_time: timestamp_pb2.Timestamp
387
388
# Long-running operation type
389
from google.api_core.operation import Operation
390
```