astronomer.providers.sftp.hooks.sftp

Module Contents

Classes

SFTPHookAsync

Interact with an SFTP server via asyncssh package

class astronomer.providers.sftp.hooks.sftp.SFTPHookAsync(sftp_conn_id=default_conn_name, host='', port=22, username='', password='', known_hosts=default_known_hosts, key_file='', passphrase='', private_key='')[source]

Bases: airflow.hooks.base.BaseHook

Interact with an SFTP server via asyncssh package

Parameters:
  • sftp_conn_id (str) – SFTP connection ID to be used for connecting to SFTP server

  • host (str) – hostname of the SFTP server

  • port (int) – port of the SFTP server

  • username (str) – username used when authenticating to the SFTP server

  • password (str) – password used when authenticating to the SFTP server Can be left blank if using a key file

  • known_hosts (str) – path to the known_hosts file on the local file system If known_hosts is set to the literal “none”, then no host verification is performed

  • key_file (str) – path to the client key file used for authentication to SFTP server

  • passphrase (str) – passphrase used with the key_file for authentication to SFTP server

conn_name_attr = ssh_conn_id
default_conn_name = sftp_default
conn_type = sftp
hook_name = SFTP
default_known_hosts = "~/.ssh/known_hosts"
async list_directory(path='')[source]

Returns a list of files on the SFTP server at the provided path

async get_file_by_pattern(path='', fnmatch_pattern='')[source]

Returns the name of a file matching the file pattern at the provided path, if one exists Otherwise, raises an AirflowException to be handled upstream for deferring

async get_mod_time(path)[source]

Makes SFTP async connection and looks for last modified time in the specific file path and returns last modification time for the file path.

Parameters:

path (str) – full path to the remote file