:py:mod:`astronomer.providers.amazon.aws.hooks.s3` ================================================== .. py:module:: astronomer.providers.amazon.aws.hooks.s3 Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: astronomer.providers.amazon.aws.hooks.s3.S3HookAsync Functions ~~~~~~~~~ .. autoapisummary:: astronomer.providers.amazon.aws.hooks.s3.provide_bucket_name_async Attributes ~~~~~~~~~~ .. autoapisummary:: astronomer.providers.amazon.aws.hooks.s3.T .. py:data:: T .. py:function:: provide_bucket_name_async(func) Function decorator that provides a bucket name taken from the connection in case no bucket name has been passed to the function. .. py:class:: S3HookAsync(*args, **kwargs) Bases: :py:obj:`astronomer.providers.amazon.aws.hooks.base_aws.AwsBaseHookAsync` Interact with AWS S3, using the aiobotocore library. .. py:attribute:: conn_type :annotation: = s3 .. py:attribute:: hook_name :annotation: = S3 .. py:method:: get_head_object(client, key, bucket_name = None) :async: Retrieves metadata of an object :param client: aiobotocore client :param bucket_name: Name of the bucket in which the file is stored :param key: S3 key that will point to the file .. py:method:: list_prefixes(client, bucket_name = None, prefix = None, delimiter = None, page_size = None, max_items = None) :async: Lists prefixes in a bucket under prefix :param client: ClientCreatorContext :param bucket_name: the name of the bucket :param prefix: a key prefix :param delimiter: the delimiter marks key hierarchy. :param page_size: pagination size :param max_items: maximum items to return :return: a list of matched prefixes .. py:method:: get_file_metadata(client, bucket_name, key) :async: Gets a list of files that a key matching a wildcard expression exists in a bucket asynchronously :param client: aiobotocore client :param bucket_name: the name of the bucket :param key: the path to the key .. py:method:: check_key(client, bucket, bucket_keys, wildcard_match) :async: Checks for all keys in bucket and returns boolean value :param client: aiobotocore client :param bucket: the name of the bucket :param bucket_keys: S3 keys that will point to the file :param wildcard_match: the path to the key .. py:method:: check_for_prefix(client, prefix, delimiter, bucket_name = None) :async: Checks that a prefix exists in a bucket :param bucket_name: the name of the bucket :param prefix: a key prefix :param delimiter: the delimiter marks key hierarchy. :return: False if the prefix does not exist in the bucket and True if it does. .. py:method:: get_files(client, bucket, bucket_keys, wildcard_match, delimiter = '/') :async: Gets a list of files in the bucket .. py:method:: is_keys_unchanged(client, bucket_name, prefix, inactivity_period = 60 * 60, min_objects = 1, previous_objects = None, inactivity_seconds = 0, allow_delete = True, last_activity_time = None) :async: Checks whether new objects have been uploaded and the inactivity_period has passed and updates the state of the sensor accordingly. :param client: aiobotocore client :param bucket_name: the name of the bucket :param prefix: a key prefix :param inactivity_period: the total seconds of inactivity to designate keys unchanged. Note, this mechanism is not real time and this operator may not return until a poke_interval after this period has passed with no additional objects sensed. :param min_objects: the minimum number of objects needed for keys unchanged sensor to be considered valid. :param previous_objects: the set of object ids found during the last poke. :param inactivity_seconds: number of inactive seconds :param last_activity_time: last activity datetime :param allow_delete: Should this sensor consider objects being deleted between pokes valid behavior. If true a warning message will be logged when this happens. If false an error will be raised. :return: dictionary with status and message :rtype: Dict