Google Cloud Composer (Orchestration Airflow) API client library for managing Apache Airflow environments
npx @tessl/cli install tessl/pypi-google-cloud-orchestration-airflow@1.17.0Google Cloud Orchestration Airflow is a Python client library for Google Cloud Composer, enabling programmatic management of Apache Airflow environments in Google Cloud Platform. It provides comprehensive API coverage for creating, scheduling, monitoring, and managing workflows through Cloud Composer's managed Apache Airflow service.
pip install google-cloud-orchestration-airflowfrom google.cloud.orchestration.airflow.service import (
EnvironmentsClient,
EnvironmentsAsyncClient,
ImageVersionsClient,
ImageVersionsAsyncClient
)For specific types:
from google.cloud.orchestration.airflow.service import (
Environment,
EnvironmentConfig,
CreateEnvironmentRequest,
ListEnvironmentsRequest,
ImageVersion
)from google.cloud.orchestration.airflow.service import EnvironmentsClient
# Initialize the client
client = EnvironmentsClient()
# List environments in a project and location
project_id = "your-project-id"
location = "us-central1"
parent = f"projects/{project_id}/locations/{location}"
request = {"parent": parent}
page_result = client.list_environments(request=request)
for environment in page_result:
print(f"Environment: {environment.name}")
print(f"State: {environment.state}")The library follows Google Cloud client library patterns with:
EnvironmentsClient, ImageVersionsClient for blocking operationsEnvironmentsAsyncClient, ImageVersionsAsyncClient for async/await patternsComplete lifecycle management of Cloud Composer environments including creation, configuration, monitoring, updates, and deletion. Supports advanced features like snapshots, upgrades, database operations, and Airflow command execution.
class EnvironmentsClient:
def create_environment(
self,
request: CreateEnvironmentRequest,
**kwargs
) -> Operation: ...
def get_environment(
self,
request: GetEnvironmentRequest,
**kwargs
) -> Environment: ...
def list_environments(
self,
request: ListEnvironmentsRequest,
**kwargs
) -> pagers.ListEnvironmentsPager: ...
def update_environment(
self,
request: UpdateEnvironmentRequest,
**kwargs
) -> Operation: ...
def delete_environment(
self,
request: DeleteEnvironmentRequest,
**kwargs
) -> Operation: ...Query available Apache Airflow image versions supported by Cloud Composer, including version metadata and compatibility information.
class ImageVersionsClient:
def list_image_versions(
self,
request: ListImageVersionsRequest,
**kwargs
) -> pagers.ListImageVersionsPager: ...Manage user workloads secrets and configuration maps within Cloud Composer environments for secure handling of sensitive data and configuration.
class EnvironmentsClient:
def create_user_workloads_secret(
self,
request: CreateUserWorkloadsSecretRequest,
**kwargs
) -> UserWorkloadsSecret: ...
def create_user_workloads_config_map(
self,
request: CreateUserWorkloadsConfigMapRequest,
**kwargs
) -> UserWorkloadsConfigMap: ...class Environment:
"""
An environment for running orchestrated workflows.
Attributes:
name (str): Environment resource name
config (EnvironmentConfig): Configuration parameters
uuid (str): Output-only UUID assigned to the environment
state (State): Output-only state of the environment
create_time (google.protobuf.timestamp_pb2.Timestamp): Creation timestamp
update_time (google.protobuf.timestamp_pb2.Timestamp): Last update timestamp
labels (Mapping[str, str]): Environment labels
satisfies_pzs (bool): Output-only flag for private zone separation
storage_config (StorageConfig): Cloud Storage configuration
"""
class EnvironmentConfig:
"""
Configuration information for an environment.
Attributes:
gke_cluster (str): Output-only GKE cluster name
dag_gcs_prefix (str): Output-only DAGs folder Cloud Storage prefix
node_count (int): Number of nodes in the environment
software_config (SoftwareConfig): Software configuration
node_config (NodeConfig): Node configuration
private_environment_config (PrivateEnvironmentConfig): Private environment configuration
web_server_config (WebServerConfig): Web server configuration
database_config (DatabaseConfig): Database configuration
web_server_network_access_control (WebServerNetworkAccessControl): Network access control
storage_config (StorageConfig): Cloud Storage configuration
encryption_config (EncryptionConfig): Encryption configuration
maintenance_window (MaintenanceWindow): Maintenance window configuration
workloads_config (WorkloadsConfig): Workloads configuration
environment_size (EnvironmentSize): Environment size preset
airflow_uri (str): Output-only Airflow web server URI
airflow_byoid_uri (str): Output-only Airflow web server BYOID URI
master_authorized_networks_config (MasterAuthorizedNetworksConfig): Master authorized networks
recovery_config (RecoveryConfig): Recovery configuration
resilience_mode (ResilienceMode): Resilience mode setting
data_retention_config (DataRetentionConfig): Data retention configuration
"""class CreateEnvironmentRequest:
"""
Request to create a new environment.
Attributes:
parent (str): Required. Location where to create environment (projects/{project}/locations/{location})
environment (Environment): Required. Environment to create
"""
class ListEnvironmentsRequest:
"""
Request to list environments.
Attributes:
parent (str): Required. List environments in location (projects/{project}/locations/{location})
page_size (int): Optional. Maximum number of environments to return
page_token (str): Optional. Token for pagination
"""
class GetEnvironmentRequest:
"""
Request to get environment details.
Attributes:
name (str): Required. Environment resource name
"""class OperationMetadata:
"""
Metadata for long-running operations.
Attributes:
state (State): Current operation state
operation_type (Type): Type of operation
resource (str): Resource being operated on
resource_uuid (str): Resource UUID
create_time (google.protobuf.timestamp_pb2.Timestamp): Operation creation time
end_time (google.protobuf.timestamp_pb2.Timestamp): Operation completion time
"""class EnvironmentSize(enum.Enum):
"""
Environment size preset options.
Values:
ENVIRONMENT_SIZE_UNSPECIFIED (0): Size unspecified
ENVIRONMENT_SIZE_SMALL (1): Small environment
ENVIRONMENT_SIZE_MEDIUM (2): Medium environment
ENVIRONMENT_SIZE_LARGE (3): Large environment
"""
class ResilienceMode(enum.Enum):
"""
Environment resilience mode options.
Values:
RESILIENCE_MODE_UNSPECIFIED (0): Resilience mode unspecified
HIGH_RESILIENCE (1): High resilience mode
"""
class State(enum.Enum):
"""
Environment state values.
Values:
STATE_UNSPECIFIED (0): State unspecified
CREATING (1): Environment is being created
RUNNING (2): Environment is running
UPDATING (3): Environment is being updated
DELETING (4): Environment is being deleted
ERROR (5): Environment is in error state
"""