airflow.providers.google.cloud.hooks.cloud_build

用于 Google Cloud Build 服务的 Hook。

属性

TIME_TO_SLEEP_IN_SECONDS

CloudBuildHook

用于 Google Cloud Build 服务的 Hook。

CloudBuildAsyncHook

用于 Google Cloud Build 服务的异步 Hook。

模块内容

airflow.providers.google.cloud.hooks.cloud_build.TIME_TO_SLEEP_IN_SECONDS = 5[source]
class airflow.providers.google.cloud.hooks.cloud_build.CloudBuildHook(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 Build 服务的 Hook。

参数:
  • gcp_conn_id (str) – 获取连接信息时使用的连接 ID。

  • impersonation_chain (str | collections.abc.Sequence[str] | None) – 可选的服务账号,用于使用短期凭据进行模拟,或者获取列表中最后一个账号的 access_token 所需的账号链列表,该账号将在请求中被模拟。如果设置为字符串,该账号必须授予发起账号 Service Account Token Creator IAM 角色。如果设置为序列,列表中的身份必须授予其直接前一个身份 Service Account Token Creator IAM 角色,列表中第一个账号将此角色授予发起账号。

get_conn(location='global')[source]

检索与 Google Cloud Build 的连接。

参数:

location (str) – 项目的位置。

返回:

Google Cloud Build 客户端对象。

返回类型:

google.cloud.devtools.cloudbuild_v1.CloudBuildClient

cancel_build(id_, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

取消正在进行的构建。

参数:
  • id – 构建的 ID。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

create_build_without_waiting_for_result(build, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

使用指定的配置启动构建,而不等待其完成。

参数:
  • build (dict | google.cloud.devtools.cloudbuild_v1.types.Build) – 要创建的构建资源。如果提供了 dict,其形式必须与 protobuf 消息 google.cloud.devtools.cloudbuild_v1.types.Build 相同。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

create_build_trigger(trigger, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

创建一个新的 BuildTrigger。

参数:
  • trigger (dict | google.cloud.devtools.cloudbuild_v1.types.BuildTrigger) – 要创建的 BuildTrigger。如果提供了 dict,其形式必须与 protobuf 消息 google.cloud.devtools.cloudbuild_v1.types.BuildTrigger 相同。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

delete_build_trigger(trigger_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

按项目 ID 和触发器 ID 删除 BuildTrigger。

参数:
  • trigger_id (str) – 要删除的 BuildTrigger 的 ID。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

get_build(id_, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

返回有关之前请求的构建的信息。

参数:
  • id – 构建的 ID。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

get_build_trigger(trigger_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

返回有关 BuildTrigger 的信息。

参数:
  • trigger_id (str) – 要获取的 BuildTrigger 的 ID。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

list_build_triggers(location='global', project_id=PROVIDE_PROJECT_ID, page_size=None, page_token=None, retry=DEFAULT, timeout=None, metadata=())[source]

列出现有的 BuildTriggers。

参数:
  • project_id (str) – 函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • location (str) – 项目的位置。

  • page_size (int | None) – 可选,在列表中返回的结果数量。

  • page_token (str | None) – 可选,用于跳到列表中特定位置的令牌。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

list_builds(location='global', project_id=PROVIDE_PROJECT_ID, page_size=None, page_token=None, filter_=None, retry=DEFAULT, timeout=None, metadata=())[source]

列出之前请求的构建。

参数:
  • project_id (str) – 函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 Google Cloud 连接中的默认项目 ID。

  • location (str) – 项目的位置。

  • page_size (int | None) – 可选,在列表中返回的结果数量。

  • page_token (int | None) – 可选,用于跳到列表中特定位置的令牌。

  • filter – 可选,用于限制结果的原始过滤文本。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

retry_build(id_, project_id=PROVIDE_PROJECT_ID, wait=True, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

使用原始构建请求创建新构建;结果可能与原构建相同,也可能不同。

参数:
  • id – 原始构建的构建 ID。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • wait (bool) – 可选,等待操作完成。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

run_build_trigger(trigger_id, source, project_id=PROVIDE_PROJECT_ID, wait=True, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

在特定的源修订版本上运行 BuildTrigger。

参数:
  • trigger_id (str) – 触发器的 ID。

  • source (dict | google.cloud.devtools.cloudbuild_v1.types.RepoSource) – 要针对此触发器构建的源。如果提供了 dict,其形式必须与 protobuf 消息 google.cloud.devtools.cloudbuild_v1.types.RepoSource 相同。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • wait (bool) – 可选,等待操作完成。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

update_build_trigger(trigger_id, trigger, project_id, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

按项目 ID 和触发器 ID 更新 BuildTrigger。

参数:
  • trigger_id (str) – 触发器的 ID。

  • trigger (dict | google.cloud.devtools.cloudbuild_v1.types.BuildTrigger) – 要创建的 BuildTrigger。如果提供了 dict,其形式必须与 protobuf 消息 google.cloud.devtools.cloudbuild_v1.types.BuildTrigger 相同。

  • project_id (str) – 可选,函数所属的 Google Cloud Project 项目 ID。如果设置为 None 或缺失,则使用 GCP 连接中的默认项目 ID。

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 可选,用于重试请求的重试对象。如果指定 None,则不会重试请求。

  • timeout (float | None) – 可选,等待请求完成的时间量,单位为秒。请注意,如果指定了 retry,则超时应用于每次单独尝试。

  • metadata (collections.abc.Sequence[tuple[str, str]]) – 可选,提供给方法的附加元数据。

  • location (str) – 项目的位置。

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

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

用于 Google Cloud Build 服务的异步 Hook。

async get_cloud_build(id_, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=(), location='global')[source]

检索具有指定 ID 的 Cloud Build。

此条目有帮助吗?