airflow.providers.google.cloud.transfers.gcs_to_sftp

此模組包含 Google Cloud Storage 到 SFTP 的 Operator。

屬性

WILDCARD

GCSToSFTPOperator

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

模組內容

airflow.providers.google.cloud.transfers.gcs_to_sftp.WILDCARD = '*'[source]
class airflow.providers.google.cloud.transfers.gcs_to_sftp.GCSToSFTPOperator(*, source_bucket, source_object, destination_path, keep_directory_structure=True, move_object=False, gcp_conn_id='google_cloud_default', sftp_conn_id='ssh_default', impersonation_chain=None, **kwargs)[source]

基類: airflow.models.BaseOperator

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

with models.DAG(
    "example_gcs_to_sftp",
    start_date=datetime(2020, 6, 19),
    schedule=None,
) as dag:
    # downloads file to /tmp/sftp/folder/subfolder/file.txt
    copy_file_from_gcs_to_sftp = GCSToSFTPOperator(
        task_id="file-copy-gsc-to-sftp",
        source_bucket="test-gcs-sftp-bucket-name",
        source_object="folder/subfolder/file.txt",
        destination_path="/tmp/sftp",
    )

    # moves file to /tmp/data.txt
    move_file_from_gcs_to_sftp = GCSToSFTPOperator(
        task_id="file-move-gsc-to-sftp",
        source_bucket="test-gcs-sftp-bucket-name",
        source_object="folder/subfolder/data.txt",
        destination_path="/tmp",
        move_object=True,
        keep_directory_structure=False,
    )

另請參閱

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

引數:
  • source_bucket (str) – 物件所在的源 Google Cloud Storage 儲存桶。(模板化)

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

  • destination_path (str) – SFTP 遠端路徑。這是上傳到 SFTP 伺服器的指定目錄路徑。

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

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

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

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

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

template_fields: collections.abc.Sequence[str] = ('source_bucket', 'source_object', 'destination_path', 'impersonation_chain')[source]
ui_color = '#f0eee4'[source]
source_bucket[source]
source_object[source]
destination_path[source]
keep_directory_structure = True[source]
move_object = False[source]
gcp_conn_id = 'google_cloud_default'[source]
sftp_conn_id = 'ssh_default'[source]
impersonation_chain = None[source]
sftp_dirs = None[source]
property sftp_hook[source]
execute(context)[source]

建立 Operator 時派生。

上下文與渲染 jinja 模板時使用的字典相同。

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

get_openlineage_facets_on_start()[source]

此條目有幫助嗎?