0
# Environment Management
1
2
Complete lifecycle management for Cloud Composer environments, including creation, configuration updates, monitoring, snapshots, database operations, and Airflow command execution.
3
4
## Capabilities
5
6
### Environment Lifecycle Operations
7
8
Create, retrieve, list, update, and delete Cloud Composer environments with full configuration control.
9
10
```python { .api }
11
def create_environment(
12
self,
13
request: CreateEnvironmentRequest,
14
retry: OptionalRetry = gapic_v1.method.DEFAULT,
15
timeout: float = None,
16
metadata: Sequence[Tuple[str, str]] = ()
17
) -> Operation:
18
"""
19
Create a new environment.
20
21
Parameters:
22
request (CreateEnvironmentRequest): Required. Request object containing parent location and environment configuration.
23
retry (OptionalRetry): Retry configuration for the request.
24
timeout (float): Request timeout in seconds.
25
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
26
27
Returns:
28
Operation: Long-running operation representing the environment creation.
29
30
Raises:
31
google.api_core.exceptions.GoogleAPICallError: If the request fails.
32
"""
33
34
def get_environment(
35
self,
36
request: GetEnvironmentRequest,
37
retry: OptionalRetry = gapic_v1.method.DEFAULT,
38
timeout: float = None,
39
metadata: Sequence[Tuple[str, str]] = ()
40
) -> Environment:
41
"""
42
Get environment details.
43
44
Parameters:
45
request (GetEnvironmentRequest): Required. Request object containing environment name.
46
retry (OptionalRetry): Retry configuration for the request.
47
timeout (float): Request timeout in seconds.
48
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
49
50
Returns:
51
Environment: Environment details including configuration and state.
52
53
Raises:
54
google.api_core.exceptions.GoogleAPICallError: If the request fails.
55
"""
56
57
def list_environments(
58
self,
59
request: ListEnvironmentsRequest,
60
retry: OptionalRetry = gapic_v1.method.DEFAULT,
61
timeout: float = None,
62
metadata: Sequence[Tuple[str, str]] = ()
63
) -> pagers.ListEnvironmentsPager:
64
"""
65
List environments in a location.
66
67
Parameters:
68
request (ListEnvironmentsRequest): Required. Request object containing parent location and pagination options.
69
retry (OptionalRetry): Retry configuration for the request.
70
timeout (float): Request timeout in seconds.
71
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
72
73
Returns:
74
pagers.ListEnvironmentsPager: Paginated list of environments.
75
76
Raises:
77
google.api_core.exceptions.GoogleAPICallError: If the request fails.
78
"""
79
80
def update_environment(
81
self,
82
request: UpdateEnvironmentRequest,
83
retry: OptionalRetry = gapic_v1.method.DEFAULT,
84
timeout: float = None,
85
metadata: Sequence[Tuple[str, str]] = ()
86
) -> Operation:
87
"""
88
Update environment configuration.
89
90
Parameters:
91
request (UpdateEnvironmentRequest): Required. Request object containing environment name, updated configuration, and field mask.
92
retry (OptionalRetry): Retry configuration for the request.
93
timeout (float): Request timeout in seconds.
94
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
95
96
Returns:
97
Operation: Long-running operation representing the environment update.
98
99
Raises:
100
google.api_core.exceptions.GoogleAPICallError: If the request fails.
101
"""
102
103
def delete_environment(
104
self,
105
request: DeleteEnvironmentRequest,
106
retry: OptionalRetry = gapic_v1.method.DEFAULT,
107
timeout: float = None,
108
metadata: Sequence[Tuple[str, str]] = ()
109
) -> Operation:
110
"""
111
Delete an environment.
112
113
Parameters:
114
request (DeleteEnvironmentRequest): Required. Request object containing environment name.
115
retry (OptionalRetry): Retry configuration for the request.
116
timeout (float): Request timeout in seconds.
117
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
118
119
Returns:
120
Operation: Long-running operation representing the environment deletion.
121
122
Raises:
123
google.api_core.exceptions.GoogleAPICallError: If the request fails.
124
"""
125
```
126
127
### Airflow Command Execution
128
129
Execute, monitor, and control Airflow CLI commands within Cloud Composer environments.
130
131
```python { .api }
132
def execute_airflow_command(
133
self,
134
request: ExecuteAirflowCommandRequest,
135
retry: OptionalRetry = gapic_v1.method.DEFAULT,
136
timeout: float = None,
137
metadata: Sequence[Tuple[str, str]] = ()
138
) -> ExecuteAirflowCommandResponse:
139
"""
140
Execute an Airflow CLI command.
141
142
Parameters:
143
request (ExecuteAirflowCommandRequest): Required. Request object containing environment and command details.
144
retry (OptionalRetry): Retry configuration for the request.
145
timeout (float): Request timeout in seconds.
146
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
147
148
Returns:
149
ExecuteAirflowCommandResponse: Response containing execution ID and initial status.
150
151
Raises:
152
google.api_core.exceptions.GoogleAPICallError: If the request fails.
153
"""
154
155
def poll_airflow_command(
156
self,
157
request: PollAirflowCommandRequest,
158
retry: OptionalRetry = gapic_v1.method.DEFAULT,
159
timeout: float = None,
160
metadata: Sequence[Tuple[str, str]] = ()
161
) -> PollAirflowCommandResponse:
162
"""
163
Poll the status of an Airflow command execution.
164
165
Parameters:
166
request (PollAirflowCommandRequest): Required. Request object containing environment and execution ID.
167
retry (OptionalRetry): Retry configuration for the request.
168
timeout (float): Request timeout in seconds.
169
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
170
171
Returns:
172
PollAirflowCommandResponse: Response containing command output and execution status.
173
174
Raises:
175
google.api_core.exceptions.GoogleAPICallError: If the request fails.
176
"""
177
178
def stop_airflow_command(
179
self,
180
request: StopAirflowCommandRequest,
181
retry: OptionalRetry = gapic_v1.method.DEFAULT,
182
timeout: float = None,
183
metadata: Sequence[Tuple[str, str]] = ()
184
) -> StopAirflowCommandResponse:
185
"""
186
Stop a running Airflow command execution.
187
188
Parameters:
189
request (StopAirflowCommandRequest): Required. Request object containing environment and execution ID.
190
retry (OptionalRetry): Retry configuration for the request.
191
timeout (float): Request timeout in seconds.
192
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
193
194
Returns:
195
StopAirflowCommandResponse: Response confirming command termination.
196
197
Raises:
198
google.api_core.exceptions.GoogleAPICallError: If the request fails.
199
"""
200
```
201
202
### Snapshot Operations
203
204
Save and restore environment snapshots for backup and migration purposes.
205
206
```python { .api }
207
def save_snapshot(
208
self,
209
request: SaveSnapshotRequest,
210
retry: OptionalRetry = gapic_v1.method.DEFAULT,
211
timeout: float = None,
212
metadata: Sequence[Tuple[str, str]] = ()
213
) -> Operation:
214
"""
215
Save environment snapshot.
216
217
Parameters:
218
request (SaveSnapshotRequest): Required. Request object containing environment and snapshot details.
219
retry (OptionalRetry): Retry configuration for the request.
220
timeout (float): Request timeout in seconds.
221
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
222
223
Returns:
224
Operation: Long-running operation representing the snapshot save process.
225
226
Raises:
227
google.api_core.exceptions.GoogleAPICallError: If the request fails.
228
"""
229
230
def load_snapshot(
231
self,
232
request: LoadSnapshotRequest,
233
retry: OptionalRetry = gapic_v1.method.DEFAULT,
234
timeout: float = None,
235
metadata: Sequence[Tuple[str, str]] = ()
236
) -> Operation:
237
"""
238
Load environment from snapshot.
239
240
Parameters:
241
request (LoadSnapshotRequest): Required. Request object containing environment and snapshot source details.
242
retry (OptionalRetry): Retry configuration for the request.
243
timeout (float): Request timeout in seconds.
244
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
245
246
Returns:
247
Operation: Long-running operation representing the snapshot load process.
248
249
Raises:
250
google.api_core.exceptions.GoogleAPICallError: If the request fails.
251
"""
252
```
253
254
### Database Operations
255
256
Manage environment database operations including failover and property retrieval.
257
258
```python { .api }
259
def database_failover(
260
self,
261
request: DatabaseFailoverRequest,
262
retry: OptionalRetry = gapic_v1.method.DEFAULT,
263
timeout: float = None,
264
metadata: Sequence[Tuple[str, str]] = ()
265
) -> Operation:
266
"""
267
Perform database failover.
268
269
Parameters:
270
request (DatabaseFailoverRequest): Required. Request object containing environment name.
271
retry (OptionalRetry): Retry configuration for the request.
272
timeout (float): Request timeout in seconds.
273
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
274
275
Returns:
276
Operation: Long-running operation representing the database failover process.
277
278
Raises:
279
google.api_core.exceptions.GoogleAPICallError: If the request fails.
280
"""
281
282
def fetch_database_properties(
283
self,
284
request: FetchDatabasePropertiesRequest,
285
retry: OptionalRetry = gapic_v1.method.DEFAULT,
286
timeout: float = None,
287
metadata: Sequence[Tuple[str, str]] = ()
288
) -> FetchDatabasePropertiesResponse:
289
"""
290
Fetch database connection properties.
291
292
Parameters:
293
request (FetchDatabasePropertiesRequest): Required. Request object containing environment name.
294
retry (OptionalRetry): Retry configuration for the request.
295
timeout (float): Request timeout in seconds.
296
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
297
298
Returns:
299
FetchDatabasePropertiesResponse: Response containing database connection details.
300
301
Raises:
302
google.api_core.exceptions.GoogleAPICallError: If the request fails.
303
"""
304
```
305
306
### Environment Upgrade and Workloads
307
308
Check upgrade availability and manage workloads within environments.
309
310
```python { .api }
311
def check_upgrade(
312
self,
313
request: CheckUpgradeRequest,
314
retry: OptionalRetry = gapic_v1.method.DEFAULT,
315
timeout: float = None,
316
metadata: Sequence[Tuple[str, str]] = ()
317
) -> Operation:
318
"""
319
Check if environment can be upgraded.
320
321
Parameters:
322
request (CheckUpgradeRequest): Required. Request object containing environment name and target image version.
323
retry (OptionalRetry): Retry configuration for the request.
324
timeout (float): Request timeout in seconds.
325
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
326
327
Returns:
328
Operation: Long-running operation that will contain upgrade check results.
329
330
Raises:
331
google.api_core.exceptions.GoogleAPICallError: If the request fails.
332
"""
333
334
def list_workloads(
335
self,
336
request: ListWorkloadsRequest,
337
retry: OptionalRetry = gapic_v1.method.DEFAULT,
338
timeout: float = None,
339
metadata: Sequence[Tuple[str, str]] = ()
340
) -> pagers.ListWorkloadsPager:
341
"""
342
List workloads in an environment.
343
344
Parameters:
345
request (ListWorkloadsRequest): Required. Request object containing environment parent and pagination options.
346
retry (OptionalRetry): Retry configuration for the request.
347
timeout (float): Request timeout in seconds.
348
metadata (Sequence[Tuple[str, str]]): Additional gRPC metadata.
349
350
Returns:
351
pagers.ListWorkloadsPager: Paginated list of workloads.
352
353
Raises:
354
google.api_core.exceptions.GoogleAPICallError: If the request fails.
355
"""
356
```
357
358
## Request/Response Types
359
360
### Environment Management Requests
361
362
```python { .api }
363
class CreateEnvironmentRequest:
364
"""
365
Request to create a new environment.
366
367
Attributes:
368
parent (str): Required. Location where to create environment (projects/{project}/locations/{location})
369
environment (Environment): Required. Environment to create
370
"""
371
372
class UpdateEnvironmentRequest:
373
"""
374
Request to update environment configuration.
375
376
Attributes:
377
name (str): Environment resource name
378
environment (Environment): Required. Patched environment configuration
379
update_mask (google.protobuf.field_mask_pb2.FieldMask): Required. Fields to update
380
"""
381
382
class DeleteEnvironmentRequest:
383
"""
384
Request to delete an environment.
385
386
Attributes:
387
name (str): Required. Environment resource name to delete
388
"""
389
```
390
391
### Command Execution Types
392
393
```python { .api }
394
class ExecuteAirflowCommandRequest:
395
"""
396
Request to execute an Airflow CLI command.
397
398
Attributes:
399
environment (str): Required. Environment resource name
400
command (str): Required. Airflow CLI command to execute
401
subcommand (str): Required. Airflow CLI subcommand
402
parameters (MutableSequence[str]): Parameters for the command
403
"""
404
405
class ExecuteAirflowCommandResponse:
406
"""
407
Response from executing an Airflow command.
408
409
Attributes:
410
execution_id (str): Unique identifier for the command execution
411
pod (str): Name of the pod where the command is executing
412
pod_namespace (str): Namespace of the pod
413
"""
414
415
class PollAirflowCommandRequest:
416
"""
417
Request to poll command execution status.
418
419
Attributes:
420
environment (str): Required. Environment resource name
421
execution_id (str): Required. Execution ID from ExecuteAirflowCommandResponse
422
pod (str): Required. Pod name from ExecuteAirflowCommandResponse
423
pod_namespace (str): Required. Pod namespace from ExecuteAirflowCommandResponse
424
"""
425
426
class PollAirflowCommandResponse:
427
"""
428
Response from polling command execution.
429
430
Attributes:
431
output (MutableSequence[Line]): Command output lines
432
output_end (bool): True if command has finished
433
exit_info (ExitInfo): Exit information if command completed
434
"""
435
```
436
437
### Snapshot Operation Types
438
439
```python { .api }
440
class SaveSnapshotRequest:
441
"""
442
Request to save environment snapshot.
443
444
Attributes:
445
environment (str): Required. Environment resource name
446
snapshot_location (str): Location in Cloud Storage to save snapshot
447
"""
448
449
class LoadSnapshotRequest:
450
"""
451
Request to load environment from snapshot.
452
453
Attributes:
454
environment (str): Required. Environment resource name
455
snapshot_path (str): Required. Cloud Storage path to snapshot
456
skip_pypi_packages_installation (bool): Skip installing PyPI packages
457
skip_environment_variables_setting (bool): Skip setting environment variables
458
skip_airflow_overrides_setting (bool): Skip setting Airflow configuration overrides
459
skip_gcs_data_copying (bool): Skip copying Cloud Storage data
460
"""
461
```