airflow.providers.google.cloud.hooks.functions

此模組包含 Google Cloud Functions Hook。

模組內容

類別

CloudFunctionsHook

Google Cloud Functions API。

屬性

TIME_TO_SLEEP_IN_SECONDS

airflow.providers.google.cloud.hooks.functions.TIME_TO_SLEEP_IN_SECONDS = 1[原始碼]
class airflow.providers.google.cloud.hooks.functions.CloudFunctionsHook(api_version, gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[原始碼]

基底類別: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Google Cloud Functions API。

Hook 中所有使用 project_id 的方法都必須使用關鍵字引數而不是位置引數來呼叫。

get_conn()[原始碼]

檢索與 Cloud Functions 的連線。

返回

Google Cloud Function 服務物件。

返回類型

googleapiclient.discovery.build

get_function(name)[原始碼]

取得具有指定名稱的 Cloud Function。

參數

name (str) – Function 的名稱。

返回

代表 Function 的 Cloud Functions 物件。

返回類型

dict

create_new_function(location, body, project_id)[原始碼]

在 body 中指定的位置建立新的 function。

參數
  • location (str) – Function 的位置。

  • body (dict) – Cloud Functions insert API 所需的 body。

  • project_id (str) – Function 所屬的 Google Cloud Project ID。如果設定為 None 或遺失,則會使用 Google Cloud 連線中的預設 Project ID。

update_function(name, body, update_mask)[原始碼]

根據指定的更新遮罩更新 Cloud Functions。

參數
  • name (str) – Function 的名稱。

  • body (dict) – cloud function patch API 所需的 body。

  • update_mask (list[str]) – 更新遮罩 - 應修補的欄位陣列。

upload_function_zip(location, zip_path, project_id)[原始碼]

上傳包含原始碼的 ZIP 檔案。

參數
  • location (str) – 建立 Function 的位置。

  • zip_path (str) – 要上傳的有效 .zip 檔案路徑。

  • project_id (str) – Function 所屬的 Google Cloud Project ID。如果設定為 None 或遺失,則會使用 Google Cloud 連線中的預設 Project ID。

返回

由 generateUploadUrl 方法傳回的上傳 URL。

返回類型

str

delete_function(name)[原始碼]

刪除指定的 Cloud Function。

參數

name (str) – Function 的名稱。

call_function(function_id, input_data, location, project_id=PROVIDE_PROJECT_ID)[原始碼]

調用已部署的 Cloud Function。

這是同步完成的,僅應用於測試目的,因為僅允許非常有限的流量。

參數
  • function_id (str) – 要調用的 function ID

  • input_data (dict) – 要傳遞至 function 的輸入

  • location (str) – Function 所在的位置。

  • project_id (str) – Function 所屬的 Google Cloud Project ID。如果設定為 None 或遺失,則會使用 Google Cloud 連線中的預設 Project ID。

這個條目對您有幫助嗎?