object_versions
¶A collection of ObjectVersion resources.A ObjectVersion Collection will include all resources by default, and extreme caution should be taken when performing actions on all resources.
all
()¶Creates an iterable of all ObjectVersion resources in the collection.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.all()
s3.ObjectVersion
)delete
(**kwargs)¶This action enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this action provides a suitable alternative to sending individual delete requests, reducing per-request overhead.
The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete action and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.
The action supports two modes for the response: verbose and quiet. By default, the action uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete action encountered an error. For a successful deletion, the action does not return any information about the delete in the response body.
When performing this action on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA Delete.
Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.
The following operations are related to DeleteObjects
:
See also: AWS API Documentation
Request Syntax
response = bucket.object_versions.delete(
MFA='string',
RequestPayer='requester',
BypassGovernanceRetention=True|False,
ExpectedBucketOwner='string',
ChecksumAlgorithm='CRC32'|'CRC32C'|'SHA1'|'SHA256'
)
s3:BypassGovernanceRetention
permission.403 Forbidden
(access denied).Indicates the algorithm used to create the checksum for the object when using the SDK. This header will not provide any additional functionality if not using the SDK. When sending this header, there must be a corresponding x-amz-checksum
or x-amz-trailer
header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request
. For more information, see Checking object integrity in the Amazon S3 User Guide .
If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm
parameter.
This checksum algorithm must be the same for all parts and it match the checksum value supplied in the CreateMultipartUpload
request.
dict
Response Syntax
{
'Deleted': [
{
'Key': 'string',
'VersionId': 'string',
'DeleteMarker': True|False,
'DeleteMarkerVersionId': 'string'
},
],
'RequestCharged': 'requester',
'Errors': [
{
'Key': 'string',
'VersionId': 'string',
'Code': 'string',
'Message': 'string'
},
]
}
Response Structure
(dict) --
Deleted (list) --
Container element for a successful delete. It identifies the object that was successfully deleted.
(dict) --
Information about the deleted object.
Key (string) --
The name of the deleted object.
VersionId (string) --
The version ID of the deleted object.
DeleteMarker (boolean) --
Specifies whether the versioned object that was permanently deleted was (true) or was not (false) a delete marker. In a simple DELETE, this header indicates whether (true) or not (false) a delete marker was created.
DeleteMarkerVersionId (string) --
The version ID of the delete marker created as a result of the DELETE operation. If you delete a specific object version, the value returned by this header is the version ID of the object version deleted.
RequestCharged (string) --
If present, indicates that the requester was successfully charged for the request.
Errors (list) --
Container for a failed delete action that describes the object that Amazon S3 attempted to delete and the error it encountered.
(dict) --
Container for all error elements.
Key (string) --
The error key.
VersionId (string) --
The version ID of the error.
Code (string) --
The error code is a string that uniquely identifies an error condition. It is meant to be read and understood by programs that detect and handle errors by type.
Amazon S3 error codes
AWS4-HMAC-SHA256
.Message (string) --
The error message contains a generic description of the error condition in English. It is intended for a human audience. Simple programs display the message directly to the end user if they encounter an error condition they don't know how or don't care to handle. Sophisticated programs with more exhaustive error handling and proper internationalization are more likely to ignore the error message.
filter
(**kwargs)¶Creates an iterable of all ObjectVersion resources in the collection filtered by kwargs passed to method. A ObjectVersion collection will include all resources by default if no filters are provided, and extreme caution should be taken when performing actions on all resources.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.filter(
Delimiter='string',
EncodingType='url',
KeyMarker='string',
MaxKeys=123,
Prefix='string',
VersionIdMarker='string',
ExpectedBucketOwner='string'
)
prefix
and the first occurrence of the delimiter are grouped under a single result element in CommonPrefixes. These groups are counted as one result against the max-keys limitation. These keys are not returned elsewhere in the response.403 Forbidden
(access denied).list(s3.ObjectVersion
)
A list of ObjectVersion resources
limit
(**kwargs)¶Creates an iterable up to a specified amount of ObjectVersion resources in the collection.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.limit(
count=123
)
s3.ObjectVersion
)page_size
(**kwargs)¶Creates an iterable of all ObjectVersion resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.page_size(
count=123
)
s3.ObjectVersion
)