| :mod:`airflow.contrib.hooks.sftp_hook` |
| ====================================== |
| |
| .. py:module:: airflow.contrib.hooks.sftp_hook |
| |
| |
| Module Contents |
| --------------- |
| |
| .. py:class:: SFTPHook(ftp_conn_id='sftp_default', *args, **kwargs) |
| |
| Bases: :class:`airflow.contrib.hooks.ssh_hook.SSHHook` |
| |
| This hook is inherited from SSH hook. Please refer to SSH hook for the input |
| arguments. |
| |
| Interact with SFTP. Aims to be interchangeable with FTPHook. |
| |
| :Pitfalls:: |
| |
| - In contrast with FTPHook describe_directory only returns size, type and |
| modify. It doesn't return unix.owner, unix.mode, perm, unix.group and |
| unique. |
| - retrieve_file and store_file only take a local full path and not a |
| buffer. |
| - If no mode is passed to create_directory it will be created with 777 |
| permissions. |
| |
| Errors that may occur throughout but should be handled downstream. |
| |
| |
| .. method:: get_conn(self) |
| |
| Returns an SFTP connection object |
| |
| |
| |
| |
| .. method:: close_conn(self) |
| |
| Closes the connection. An error will occur if the |
| connection wasnt ever opened. |
| |
| |
| |
| |
| .. method:: describe_directory(self, path) |
| |
| Returns a dictionary of {filename: {attributes}} for all files |
| on the remote system (where the MLSD command is supported). |
| |
| :param path: full path to the remote directory |
| :type path: str |
| |
| |
| |
| |
| .. method:: list_directory(self, path) |
| |
| Returns a list of files on the remote system. |
| |
| :param path: full path to the remote directory to list |
| :type path: str |
| |
| |
| |
| |
| .. method:: create_directory(self, path, mode=777) |
| |
| Creates a directory on the remote system. |
| |
| :param path: full path to the remote directory to create |
| :type path: str |
| :param mode: int representation of octal mode for directory |
| |
| |
| |
| |
| .. method:: delete_directory(self, path) |
| |
| Deletes a directory on the remote system. |
| |
| :param path: full path to the remote directory to delete |
| :type path: str |
| |
| |
| |
| |
| .. method:: retrieve_file(self, remote_full_path, local_full_path) |
| |
| Transfers the remote file to a local location. |
| If local_full_path is a string path, the file will be put |
| at that location |
| |
| :param remote_full_path: full path to the remote file |
| :type remote_full_path: str |
| :param local_full_path: full path to the local file |
| :type local_full_path: str |
| |
| |
| |
| |
| .. method:: store_file(self, remote_full_path, local_full_path) |
| |
| Transfers a local file to the remote location. |
| If local_full_path_or_buffer is a string path, the file will be read |
| from that location |
| |
| :param remote_full_path: full path to the remote file |
| :type remote_full_path: str |
| :param local_full_path: full path to the local file |
| :type local_full_path: str |
| |
| |
| |
| |
| .. method:: delete_file(self, path) |
| |
| Removes a file on the FTP Server |
| |
| :param path: full path to the remote file |
| :type path: str |
| |
| |
| |
| |
| .. method:: get_mod_time(self, path) |
| |
| |
| |
| |
| .. method:: path_exists(self, path) |
| |
| Returns True if a remote entity exists |
| |
| :param path: full path to the remote file or directory |
| :type path: str |
| |
| |
| |
| |