blob: 0750c45068c6cfcb7e025bf4354aba8a752fa532 [file] [log] [blame]
:py:mod:`airflow.providers.alibaba.cloud.hooks.oss`
===================================================
.. py:module:: airflow.providers.alibaba.cloud.hooks.oss
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.alibaba.cloud.hooks.oss.OSSHook
Functions
~~~~~~~~~
.. autoapisummary::
airflow.providers.alibaba.cloud.hooks.oss.provide_bucket_name
airflow.providers.alibaba.cloud.hooks.oss.unify_bucket_name_and_key
Attributes
~~~~~~~~~~
.. autoapisummary::
airflow.providers.alibaba.cloud.hooks.oss.T
.. py:data:: T
.. py:function:: provide_bucket_name(func)
Function decorator that unifies bucket name and key taken from the key
in case no bucket name and at least a key has been passed to the function.
.. py:function:: unify_bucket_name_and_key(func)
Function decorator that unifies bucket name and key taken from the key
in case no bucket name and at least a key has been passed to the function.
.. py:class:: OSSHook(region = None, oss_conn_id='oss_default', *args, **kwargs)
Bases: :py:obj:`airflow.hooks.base.BaseHook`
Interact with Alibaba Cloud OSS, using the oss2 library.
.. py:attribute:: conn_name_attr
:annotation: = alibabacloud_conn_id
.. py:attribute:: default_conn_name
:annotation: = oss_default
.. py:attribute:: conn_type
:annotation: = oss
.. py:attribute:: hook_name
:annotation: = OSS
.. py:method:: get_conn(self)
Returns connection for the hook.
.. py:method:: parse_oss_url(ossurl)
:staticmethod:
Parses the OSS Url into a bucket name and key.
:param ossurl: The OSS Url to parse.
:return: the parsed bucket name and key
.. py:method:: object_exists(self, key, bucket_name = None)
Check if object exists.
:param key: the path of the object
:param bucket_name: the name of the bucket
:return: True if it exists and False if not.
:rtype: bool
.. py:method:: get_bucket(self, bucket_name = None)
Returns a oss2.Bucket object
:param bucket_name: the name of the bucket
:return: the bucket object to the bucket name.
:rtype: oss2.api.Bucket
.. py:method:: load_string(self, key, content, bucket_name = None)
Loads a string to OSS
:param key: the path of the object
:param content: str to set as content for the key.
:param bucket_name: the name of the bucket
.. py:method:: upload_local_file(self, key, file, bucket_name = None)
Upload a local file to OSS
:param key: the OSS path of the object
:param file: local file to upload.
:param bucket_name: the name of the bucket
.. py:method:: download_file(self, key, local_file, bucket_name = None)
Download file from OSS
:param key: key of the file-like object to download.
:param local_file: local path + file name to save.
:param bucket_name: the name of the bucket
:return: the file name.
:rtype: str
.. py:method:: delete_object(self, key, bucket_name = None)
Delete object from OSS
:param key: key of the object to delete.
:param bucket_name: the name of the bucket
.. py:method:: delete_objects(self, key, bucket_name = None)
Delete objects from OSS
:param key: keys list of the objects to delete.
:param bucket_name: the name of the bucket
.. py:method:: delete_bucket(self, bucket_name = None)
Delete bucket from OSS
:param bucket_name: the name of the bucket
.. py:method:: create_bucket(self, bucket_name = None)
Create bucket
:param bucket_name: the name of the bucket
.. py:method:: append_string(self, bucket_name, content, key, pos)
Append string to a remote existing file
:param bucket_name: the name of the bucket
:param content: content to be appended
:param key: oss bucket key
:param pos: position of the existing file where the content will be appended
.. py:method:: read_key(self, bucket_name, key)
Read oss remote object content with the specified key
:param bucket_name: the name of the bucket
:param key: oss bucket key
.. py:method:: head_key(self, bucket_name, key)
Get meta info of the specified remote object
:param bucket_name: the name of the bucket
:param key: oss bucket key
.. py:method:: key_exist(self, bucket_name, key)
Find out whether the specified key exists in the oss remote storage
:param bucket_name: the name of the bucket
:param key: oss bucket key
.. py:method:: get_credential(self)
.. py:method:: get_default_region(self)