airflow.providers.google.suite.hooks.drive
¶
Google Drive 服務的 Hook。
模組內容¶
類別¶
Google Drive API 的 Hook。 |
- class airflow.providers.google.suite.hooks.drive.GoogleDriveHook(api_version='v3', gcp_conn_id='google_cloud_default', impersonation_chain=None)[原始碼]¶
基底類別:
airflow.providers.google.common.hooks.base_google.GoogleBaseHook
Google Drive API 的 Hook。
- 參數
api_version (str) – 使用的 API 版本 (例如 v3)。
gcp_conn_id (str) – 取得連線資訊時使用的連線 ID。
impersonation_chain (str | collections.abc.Sequence[str] | None) – 選擇性服務帳戶,用於模擬使用短期憑證,或用於取得清單中最後一個帳戶的 access_token 的鏈結帳戶清單,該帳戶將在請求中被模擬。如果設定為字串,則帳戶必須授予原始帳戶「服務帳戶權杖建立者」IAM 角色。如果設定為序列,則清單中的身分必須將「服務帳戶權杖建立者」IAM 角色授予直接前一個身分,清單中的第一個帳戶將此角色授予原始帳戶。
- get_media_request(file_id)[原始碼]¶
傳回 Google Drive 物件的 get_media http 請求。
- 參數
file_id (str) – Google Drive 檔案 ID
- 返回
request
- 返回類型
googleapiclient.http.HttpRequest
- exists(folder_id, file_name, drive_id=None, *, include_trashed=True)[原始碼]¶
檢查 Google Drive 資料夾中是否存在檔案。
- get_file_id(folder_id, file_name, drive_id=None, *, include_trashed=True)[原始碼]¶
傳回 Google Drive 檔案的檔案 ID。
- upload_file(local_location, remote_location, chunk_size=100 * 1024 * 1024, resumable=False, folder_id='root', show_full_target_path=True)[原始碼]¶
將本機可用的檔案上傳到 Google Drive 服務。
- 參數
local_location (str) – 檔案可用的路徑。
remote_location (str) – 檔案將傳送到的路徑
chunk_size (int) – 檔案將以這麼多位元組的區塊上傳。僅在 resumable=True 時使用。如果檔案要以單一區塊上傳,請傳入值 -1。請注意,Google App Engine 對請求大小有 5MB 的限制,因此您永遠不應將區塊大小設定為大於 5MB,或設定為 -1。
resumable (bool) – 如果這是可續傳上傳,則為 True。False 表示以單一請求上傳。
folder_id (str) – remote_location 的基本/根資料夾 ID(資料夾的雲端硬碟 URL 的一部分)。
show_full_target_path (bool) – 如果為 true,則會在日誌中顯示完整的可用檔案路徑。
- 返回
檔案 ID
- 返回類型