airflow.providers.google.cloud.hooks.functions
此模組包含一個 Google Cloud Functions Hook。
模組內容
-
airflow.providers.google.cloud.hooks.functions.TIME_TO_SLEEP_IN_SECONDS = 1[source]
-
class airflow.providers.google.cloud.hooks.functions.CloudFunctionsHook(api_version, gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]
Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook
Google Cloud Functions API。
Hook 中所有使用了 project_id 的方法都必須使用關鍵字引數呼叫,而不是位置引數。
-
api_version[source]
-
get_conn()[source]
檢索到 Cloud Functions 的連線。
- 返回:
Google Cloud Function 服務物件。
- 返回型別:
googleapiclient.discovery.build
-
get_function(name)[source]
獲取具有指定名稱的 Cloud Function。
- 引數:
name (str) – 函式的名稱。
- 返回:
表示該函式的 Cloud Functions 物件。
- 返回型別:
dict
-
create_new_function(location, body, project_id)[source]
在 body 中指定的位置建立一個新函式。
- 引數:
-
-
update_function(name, body, update_mask)[source]
根據指定的 update mask 更新 Cloud Functions。
- 引數:
-
-
upload_function_zip(location, zip_path, project_id)[source]
上傳包含原始碼的 ZIP 檔案。
- 引數:
location (str) – 建立函式的位置。
zip_path (str) – 要上傳的有效 .zip 檔案的路徑。
project_id (str) – 函式所屬的 Google Cloud Project ID。如果設定為 None 或缺失,則使用 Google Cloud 連線中的預設 Project ID。
- 返回:
由 generateUploadUrl 方法返回的上傳 URL。
- 返回型別:
str
-
delete_function(name)[source]
刪除指定的 Cloud Function。
- 引數:
name (str) – 函式的名稱。
-
call_function(function_id, input_data, location, project_id=PROVIDE_PROJECT_ID)[source]
呼叫已部署的 Cloud Function。
這是同步執行的,並且僅應用於測試目的,因為允許的流量非常有限。
- 引數:
function_id (str) – 要呼叫的函式 ID
input_data (dict) – 要傳遞給函式的輸入
location (str) – 函式所在的位置。
project_id (str) – 函式所屬的 Google Cloud Project ID。如果設定為 None 或缺失,則使用 Google Cloud 連線中的預設 Project ID。