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)[source]¶
基类:
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,并在请求中模拟该账号。如果设置为字符串,该账号必须授予发起账号 Service Account Token Creator IAM 角色。如果设置为序列,列表中的身份必须授予直接前置身份 Service Account Token Creator IAM 角色,列表中第一个账号授予发起账号该角色。
- get_media_request(file_id)[source]¶
返回对 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)[source]¶
检查 Google Drive 文件夹中是否存在文件。
- get_file_id(folder_id, file_name, drive_id=None, *, include_trashed=True)[source]¶
返回 Google Drive 文件的文件 ID。
- upload_file(local_location, remote_location, chunk_size=100 * 1024 * 1024, resumable=False, folder_id='root', show_full_target_path=True)[source]¶
将本地文件上传到 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(文件夹 Drive URL 的一部分)。
show_full_target_path (bool) – 如果为 True,则在日志中显示完整的可用文件路径。
- 返回::
文件 ID
- 返回类型::