airflow.providers.google.cloud.hooks.cloud_composer

CloudComposerHook

用于 Google Cloud Composer API 的连接器。

CloudComposerAsyncHook

用于 Google Cloud Composer 异步 API 的连接器。

模块内容

class airflow.providers.google.cloud.hooks.cloud_composer.CloudComposerHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

基类: airflow.providers.google.common.hooks.base_google.GoogleBaseHook, airflow.providers.google.common.hooks.operation_helpers.OperationHelper

用于 Google Cloud Composer API 的连接器。

client_options[source]
get_environment_client()[source]

获取允许访问环境服务的客户端库对象。

get_image_versions_client()[source]

获取允许访问镜像版本服务的客户端库对象。

get_operation(operation_name)[source]
get_environment_name(project_id, region, environment_id)[source]
get_parent(project_id, region)[source]
create_environment(project_id, region, environment, retry=DEFAULT, timeout=None, metadata=())[source]

创建新环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment (google.cloud.orchestration.airflow.service_v1.types.Environment | dict) – 要创建的环境。这对应于 request 实例上的 environment 字段;如果提供了 request,则不应设置此字段。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

delete_environment(project_id, region, environment_id, retry=DEFAULT, timeout=None, metadata=())[source]

删除环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 必需。服务所属的 Google Cloud 环境 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

get_environment(project_id, region, environment_id, retry=DEFAULT, timeout=None, metadata=())[source]

获取现有环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 必需。服务所属的 Google Cloud 环境 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

list_environments(project_id, region, page_size=None, page_token=None, retry=DEFAULT, timeout=None, metadata=())[source]

列出环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • page_size (int | None) – 要返回的最大环境数量。

  • page_token (str | None) – 前一次 List 请求返回的 next_page_token 值(若有)。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

update_environment(project_id, region, environment_id, environment, update_mask, retry=DEFAULT, timeout=None, metadata=())[source]

更新环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 必需。服务所属的 Google Cloud 环境 ID。

  • environment (google.cloud.orchestration.airflow.service_v1.types.Environment | dict) –

    一个补丁环境。由 updateMask 指定的字段将从补丁环境复制到正在更新的环境中。

    这对应于 request 实例上的 environment 字段;如果提供了 request,则不应设置此字段。

  • update_mask (dict | google.protobuf.field_mask_pb2.FieldMask) – 必需。相对于 Environment 要更新的字段路径的逗号分隔列表。如果提供的是字典,则其形式必须与 protobuf 消息 FieldMask 相同

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

list_image_versions(project_id, region, page_size=None, page_token=None, include_past_releases=False, retry=DEFAULT, timeout=None, metadata=())[source]

列出指定位置的 ImageVersions。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • page_size (int | None) – 要返回的最大环境数量。

  • page_token (str | None) – 前一次 List 请求返回的 next_page_token 值(若有)。

  • include_past_releases (bool) – 包含过去版本的标志

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

execute_airflow_command(project_id, region, environment_id, command, subcommand, parameters, retry=DEFAULT, timeout=None, metadata=())[source]

针对指定的 Composer 环境执行 Airflow 命令。

参数:
  • project_id (str) – 服务所属的 Google Cloud 项目 ID。

  • region (str) – 服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 服务所属的 Google Cloud 环境 ID。

  • command (str) – Airflow 命令。

  • subcommand (str) – Airflow 子命令。

  • parameters (collections.abc.MutableSequence[str]) – 作为参数数组传递给 Airflow 命令/子命令的参数。它可能包含位置参数,例如 ["my-dag-id"];键值参数,例如 ["--foo=bar"]["--foo","bar"];或其它标志,例如 ["-f"]

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

poll_airflow_command(project_id, region, environment_id, execution_id, pod, pod_namespace, next_line_number, retry=DEFAULT, timeout=None, metadata=())[source]

轮询指定 Composer 环境的 Airflow 命令执行结果。

参数:
  • project_id (str) – 服务所属的 Google Cloud 项目 ID。

  • region (str) – 服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 服务所属的 Google Cloud 环境 ID。

  • execution_id (str) – 命令执行的唯一 ID。

  • pod (str) – 执行命令的 Pod 名称。

  • pod_namespace (str) – 执行命令的 Pod 命名空间。

  • next_line_number (int) – 应从中获取新日志的行号。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

wait_command_execution_result(project_id, region, environment_id, execution_cmd_info, retry=DEFAULT, timeout=None, metadata=(), poll_interval=10)[source]
class airflow.providers.google.cloud.hooks.cloud_composer.CloudComposerAsyncHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

基类: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

用于 Google Cloud Composer 异步 API 的连接器。

client_options[source]
get_environment_client()[source]

获取允许访问环境服务的客户端库对象。

get_environment_name(project_id, region, environment_id)[source]
get_parent(project_id, region)[source]
async get_operation(operation_name)[source]
async create_environment(project_id, region, environment, retry=DEFAULT, timeout=None, metadata=())[source]

创建新环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment (google.cloud.orchestration.airflow.service_v1.types.Environment | dict) – 要创建的环境。这对应于 request 实例上的 environment 字段;如果提供了 request,则不应设置此字段。

  • retry (google.api_core.retry_async.AsyncRetry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

async delete_environment(project_id, region, environment_id, retry=DEFAULT, timeout=None, metadata=())[source]

删除环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 必需。服务所属的 Google Cloud 环境 ID。

  • retry (google.api_core.retry_async.AsyncRetry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

async update_environment(project_id, region, environment_id, environment, update_mask, retry=DEFAULT, timeout=None, metadata=())[source]

更新环境。

参数:
  • project_id (str) – 必需。服务所属的 Google Cloud 项目 ID。

  • region (str) – 必需。服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 必需。服务所属的 Google Cloud 环境 ID。

  • environment (google.cloud.orchestration.airflow.service_v1.types.Environment | dict) –

    一个补丁环境。由 updateMask 指定的字段将从补丁环境复制到正在更新的环境中。

    这对应于 request 实例上的 environment 字段;如果提供了 request,则不应设置此字段。

  • update_mask (dict | google.protobuf.field_mask_pb2.FieldMask) – 必需。相对于 Environment 要更新的字段路径的逗号分隔列表。如果提供的是字典,则其形式必须与 protobuf 消息 FieldMask 相同

  • retry (google.api_core.retry_async.AsyncRetry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

async execute_airflow_command(project_id, region, environment_id, command, subcommand, parameters, retry=DEFAULT, timeout=None, metadata=())[source]

针对指定的 Composer 环境执行 Airflow 命令。

参数:
  • project_id (str) – 服务所属的 Google Cloud 项目 ID。

  • region (str) – 服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 服务所属的 Google Cloud 环境 ID。

  • command (str) – Airflow 命令。

  • subcommand (str) – Airflow 子命令。

  • parameters (collections.abc.MutableSequence[str]) – 作为参数数组传递给 Airflow 命令/子命令的参数。它可能包含位置参数,例如 ["my-dag-id"];键值参数,例如 ["--foo=bar"]["--foo","bar"];或其它标志,例如 ["-f"]

  • retry (google.api_core.retry_async.AsyncRetry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

async poll_airflow_command(project_id, region, environment_id, execution_id, pod, pod_namespace, next_line_number, retry=DEFAULT, timeout=None, metadata=())[source]

轮询指定 Composer 环境的 Airflow 命令执行结果。

参数:
  • project_id (str) – 服务所属的 Google Cloud 项目 ID。

  • region (str) – 服务所属的 Google Cloud 区域 ID。

  • environment_id (str) – 服务所属的 Google Cloud 环境 ID。

  • execution_id (str) – 命令执行的唯一 ID。

  • pod (str) – 执行命令的 Pod 名称。

  • pod_namespace (str) – 执行命令的 Pod 命名空间。

  • next_line_number (int) – 应从中获取新日志的行号。

  • retry (google.api_core.retry_async.AsyncRetry | google.api_core.gapic_v1.method._MethodDefault) – 指定哪些错误(若有)应重试。

  • timeout (float | None) – 此请求的超时时间。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 应作为元数据随请求一起发送的字符串。

async wait_command_execution_result(project_id, region, environment_id, execution_cmd_info, retry=DEFAULT, timeout=None, metadata=(), poll_interval=10)[source]

此条目有帮助吗?