pendant.aws.s3 module¶
-
class
pendant.aws.s3.
S3Uri
(path: Union[str, S3Uri])[source]¶ Bases:
object
An S3 URI which conforms to RFC 3986 formatting.
Parameters: path – The S3 URI path. Examples
>>> uri = S3Uri('s3://mybucket/prefix') >>> uri.scheme 's3://' >>> uri.bucket 'mybucket' >>> uri / 'myobject' S3Uri('s3://mybucket/prefix/myobject')
-
delimiter
= '/'¶
-
scheme
¶ Return the RFC 3986 scheme of this URI.
Example
>>> uri = S3Uri('s3://mybucket/myobject') >>> uri.scheme 's3://'
-
bucket
¶ Return the S3 bucket of this URI.
Example
>>> uri = S3Uri('s3://mybucket/myobject') >>> uri.bucket 'mybucket'
-
key
¶ Return the S3 key of this URI.
Example
>>> uri = S3Uri('s3://mybucket/myobject') >>> uri.key 'myobject'
-
add_suffix
(suffix: str) → pendant.aws.s3.S3Uri[source]¶ Add a suffix to this S3 URI.
Parameters: suffix – Append this suffix to the URI. Examples
>>> uri = S3Uri('s3://mybucket/myobject.bam') >>> uri.add_suffix('.bai') S3Uri('s3://mybucket/myobject.bam.bai')
This is equivalent to:
>>> S3Uri('s3://mybucket/myobject.bam') + '.bai' S3Uri('s3://mybucket/myobject.bam.bai')
-
-
pendant.aws.s3.
s3api_head_object
(bucket: str, key: str, profile: str = 'default') → Dict[source]¶ Use the
awscli
to make a GET request on an S3 object’s metadata.Parameters: - bucket – The S3 bucket name.
- key – The S3 object key.
- profile – The AWS profile to use, defaults to “default”.
Returns: A dictionary of object metadata, if the object exists.
-
pendant.aws.s3.
s3api_object_exists
(bucket: str, key: str, profile: str = 'default') → bool[source]¶ Use the
awscli
to test if an S3 object exists.Parameters: - bucket – The S3 bucket name.
- key – The S3 object key.
- profile – The AWS profile to use, defaults to “default”.
-
pendant.aws.s3.
s3_object_exists
(bucket: str, key: str) → bool[source]¶ Use
boto3.S3.Object
to test if an S3 object exists.Parameters: - bucket – The S3 bucket name.
- key – The S3 object key.