airflow.providers.samba.transfers.gcs_to_samba

此模組包含 Google Cloud Storage 到 Samba 的運算子。

屬性

WILDCARD

GCSToSambaOperator

將檔案從 Google Cloud Storage 儲存桶傳輸到 SMB 伺服器。

模組內容

airflow.providers.samba.transfers.gcs_to_samba.WILDCARD = '*'[source]
class airflow.providers.samba.transfers.gcs_to_samba.GCSToSambaOperator(*, source_bucket, source_object, destination_path, keep_directory_structure=True, move_object=False, gcp_conn_id='google_cloud_default', samba_conn_id='samba_default', impersonation_chain=None, buffer_size=None, **kwargs)[source]

基類: airflow.models.BaseOperator

將檔案從 Google Cloud Storage 儲存桶傳輸到 SMB 伺服器。

with models.DAG(
    "example_gcs_to_smb",
    start_date=datetime(2020, 6, 19),
    schedule=None,
) as dag:
    # downloads file to media/folder/subfolder/file.txt
    copy_file_from_gcs_to_smb = GCSToSambaOperator(
        task_id="file-copy-gcs-to-smb",
        source_bucket="test-gcs-sftp-bucket-name",
        source_object="folder/subfolder/file.txt",
        destination_path="media",
    )

    # moves file to media/data.txt
    move_file_from_gcs_to_smb = GCSToSambaOperator(
        task_id="file-move-gcs-to-smb",
        source_bucket="test-gcs-sftp-bucket-name",
        source_object="folder/subfolder/data.txt",
        destination_path="media",
        move_object=True,
        keep_directory_structure=False,
    )

另請參閱

有關如何使用此運算子的更多資訊,請查閱指南:運算子

引數:
  • source_bucket (str) – 源 Google Cloud Storage 儲存桶。(可使用模板)

  • source_object (str) – 要在 Google Cloud Storage 儲存桶中複製的物件的源名稱。(可使用模板)您只能在儲存桶內的物件(檔名)中使用一個萬用字元。萬用字元可以出現在物件名稱內部或物件名稱末尾。不支援將萬用字元附加到儲存桶名稱後。

  • destination_path (str) – SMB 遠端路徑。這是 SMB 共享名中指定的目錄路徑,用於將檔案上傳到 SMB 伺服器。

  • keep_directory_structure (bool) – (可選) 當設定為 False 時,將在 destination_path 中重新建立儲存桶中檔案的路徑。

  • move_object (bool) – 當 move object 為 True 時,物件將被移動而不是複製到新位置。這相當於 mv 命令,而不是 cp 命令。

  • gcp_conn_id (str) – (可選) 用於連線到 Google Cloud 的連線 ID。

  • samba_conn_id (str) – SMB 連線 ID。用於建立與 SMB 伺服器連線的名稱或識別符號。

  • impersonation_chain (str | collections.abc.Sequence[str] | None) – 可選的服務賬號,用於使用短期憑據進行模擬,或獲取列表中最後一個賬號的 access_token 所需的鏈式賬號列表,該 access_token 將在請求中被模擬。如果設定為字串,則發起賬號必須授予目標賬號“服務賬號令牌建立者 (Service Account Token Creator)”IAM 角色。如果設定為序列,則列表中的身份必須授予直接前一個身份“服務賬號令牌建立者”IAM 角色,列表中的第一個賬號將此角色授予發起賬號。(可使用模板)

  • buffer_size (int | None) – 可選地指定傳送到 Samba 的塊大小(以位元組為單位)。較大的緩衝區長度可能會減少上傳大檔案所需的時間。預設長度由 shutil 確定,為 64 KB。

template_fields: collections.abc.Sequence[str] = ('source_bucket', 'source_object', 'destination_path', 'impersonation_chain')
ui_color = '#f0eee4'
source_bucket
source_object
destination_path
keep_directory_structure = True
move_object = False
gcp_conn_id = 'google_cloud_default'
samba_conn_id = 'samba_default'
impersonation_chain = None
sftp_dirs = None
buffer_size = None
execute(context)

建立運算子時派生。

Context 是與渲染 Jinja 模板時使用的字典相同。

請參閱 get_template_context 以獲取更多上下文。

此條目有幫助嗎?