airflow.providers.samba.transfers.gcs_to_samba

這個模組包含 Google Cloud Storage 到 Samba operator。

模組內容

類別

GCSToSambaOperator

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

屬性

WILDCARD

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,
    )

參見

如需更多關於如何使用此 operator 的資訊,請參閱指南: Operator

參數
  • 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 所需的帳戶鏈結列表,該帳戶將在請求中被模擬身分。如果設定為字串,則帳戶必須授予原始帳戶 Service Account Token Creator IAM 角色。如果設定為序列,則列表中的身分必須授予緊鄰的前一個身分 Service Account Token Creator IAM 角色,列表中的第一個帳戶將此角色授予原始帳戶(已模板化)。

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

template_fields: collections.abc.Sequence[str] = ('source_bucket', 'source_object', 'destination_path', 'impersonation_chain')[source]
ui_color = '#f0eee4'[source]
execute(context)[source]

在建立 operator 時衍生。

Context 是與呈現 jinja 模板時使用的字典相同的字典。

有關更多上下文,請參閱 get_template_context。

這個條目有幫助嗎?