Skip to content

list_object_versions async

list_object_versions(
    bucket: BucketName,
    *,
    config_overrides: Optional[AsyncS3ClientConfig] = None,
    delimiter: Optional[Delimiter] = None,
    encoding_type: Optional[EncodingType] = None,
    key_marker: Optional[KeyMarker] = None,
    max_keys: Optional[MaxKeys] = None,
    prefix: Optional[Prefix] = None,
    version_id_marker: Optional[VersionIdMarker] = None,
    expected_bucket_owner: Optional[AccountId] = None,
    request_payer: Optional[RequestPayer] = None,
    optional_object_attributes: Optional[OptionalObjectAttributesList] = None,
) -> ListObjectVersionsOutput

This operation is not supported for directory buckets.

Returns metadata about all versions of the objects in a bucket. You can also use request parameters as selection criteria to return metadata about a subset of all the object versions.

To use this operation, you must have permission to perform the s3:ListBucketVersions action. Be aware of the name difference.

A 200 OK response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.

To use this operation, you must have READ access to the bucket.

The following operations are related to ListObjectVersions:

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

  • bucket (BucketName) –

    The bucket name that contains the objects.

  • delimiter (Optional[Delimiter], default: None ) –

    A delimiter is a character that you specify to group keys. All keys that contain the same string between the 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.

    CommonPrefixes is filtered out from results if it is not lexicographically greater than the key-marker.

  • key_marker (Optional[KeyMarker], default: None ) –

    Specifies the key to start with when listing objects in a bucket.

  • max_keys (Optional[MaxKeys], default: None ) –

    Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names. The response might contain fewer keys but will never contain more. If additional keys satisfy the search criteria, but were not returned because max-keys was exceeded, the response contains true. To return the additional keys, see key-marker and version-id-marker.

  • prefix (Optional[Prefix], default: None ) –

    Use this parameter to select only those keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys. (You can think of using prefix to make groups in the same way that you'd use a folder in a file system.) You can use prefix with delimiter to roll up numerous objects into a single result under CommonPrefixes.

  • version_id_marker (Optional[VersionIdMarker], default: None ) –

    Specifies the object version you want to start listing from.

  • expected_bucket_owner (Optional[AccountId], default: None ) –

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

  • optional_object_attributes (Optional[OptionalObjectAttributesList], default: None ) –

    Specifies the optional fields that you want returned in the response. Fields that you do not specify are not returned.

Raises:

Examples:

To list object versions The following example returns versions of an object with specific key name prefix.

>>> await client.list_object_versions(bucket='examplebucket', prefix='HappyFace.jpg')
Source code in docs_src/capo_s3/_services/async_s3.py
async def list_object_versions(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    *,
    config_overrides: Optional[AsyncS3ClientConfig] = None,
    delimiter: Optional["capo_s3.types.delimiter.Delimiter"] = None,
    encoding_type: Optional["capo_s3.types.encoding_type.EncodingType"] = None,
    key_marker: Optional["capo_s3.types.key_marker.KeyMarker"] = None,
    max_keys: Optional["capo_s3.types.max_keys.MaxKeys"] = None,
    prefix: Optional["capo_s3.types.prefix.Prefix"] = None,
    version_id_marker: Optional[
        "capo_s3.types.version_id_marker.VersionIdMarker"
    ] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
    request_payer: Optional["capo_s3.types.request_payer.RequestPayer"] = None,
    optional_object_attributes: Optional[
        "capo_s3.types.optional_object_attributes_list.OptionalObjectAttributesList"
    ] = None,
) -> "capo_s3.types.list_object_versions_output.ListObjectVersionsOutput":
    """<note> <p>This operation is not supported for directory buckets.</p> </note> <p>Returns metadata about all versions of the objects in a bucket. You can also use request parameters as selection criteria to return metadata about a subset of all the object versions.</p> <important> <p> To use this operation, you must have permission to perform the <code>s3:ListBucketVersions</code> action. Be aware of the name difference. </p> </important> <note> <p> A <code>200 OK</code> response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.</p> </note> <p>To use this operation, you must have READ access to the bucket.</p> <p>The following operations are related to <code>ListObjectVersions</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html">ListObjectsV2</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html">GetObject</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html">PutObject</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html">DeleteObject</a> </p> </li> </ul> <important> <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p> </important>

    Args:
        bucket: <p>The bucket name that contains the objects. </p>
        delimiter: <p>A delimiter is a character that you specify to group keys. All keys that contain the same string between the <code>prefix</code> and the first occurrence of the delimiter are grouped under a single result element in <code>CommonPrefixes</code>. These groups are counted as one result against the <code>max-keys</code> limitation. These keys are not returned elsewhere in the response.</p> <p> <code>CommonPrefixes</code> is filtered out from results if it is not lexicographically greater than the key-marker.</p>
        key_marker: <p>Specifies the key to start with when listing objects in a bucket.</p>
        max_keys: <p>Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names. The response might contain fewer keys but will never contain more. If additional keys satisfy the search criteria, but were not returned because <code>max-keys</code> was exceeded, the response contains <code><isTruncated>true</isTruncated></code>. To return the additional keys, see <code>key-marker</code> and <code>version-id-marker</code>.</p>
        prefix: <p>Use this parameter to select only those keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys. (You can think of using <code>prefix</code> to make groups in the same way that you'd use a folder in a file system.) You can use <code>prefix</code> with <code>delimiter</code> to roll up numerous objects into a single result under <code>CommonPrefixes</code>. </p>
        version_id_marker: <p>Specifies the object version you want to start listing from.</p>
        expected_bucket_owner: <p>The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code <code>403 Forbidden</code> (access denied).</p>
        optional_object_attributes: <p>Specifies the optional fields that you want returned in the response. Fields that you do not specify are not returned.</p>

    Raises:
        capo_s3.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list object versions
        The following example returns versions of an object with specific key name prefix.

        >>> await client.list_object_versions(bucket='examplebucket', prefix='HappyFace.jpg')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_s3.types.list_object_versions_request.ListObjectVersionsRequest]",
    ) -> AsyncOperationResponse[
        "capo_s3.types.list_object_versions_output.ListObjectVersionsOutput"
    ]:
        import capo_s3._operations.amazon_s3.list_object_versions

        (
            output,
            http_response,
        ) = await capo_s3._operations.amazon_s3.list_object_versions.async_list_object_versions(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListObjectVersions")
    )
    input_: capo_s3.types.list_object_versions_request.ListObjectVersionsRequest = {
        "bucket": bucket
    }
    if delimiter is not None:
        input_["delimiter"] = delimiter
    if encoding_type is not None:
        input_["encoding_type"] = encoding_type
    if key_marker is not None:
        input_["key_marker"] = key_marker
    if max_keys is not None:
        input_["max_keys"] = max_keys
    if prefix is not None:
        input_["prefix"] = prefix
    if version_id_marker is not None:
        input_["version_id_marker"] = version_id_marker
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner
    if request_payer is not None:
        input_["request_payer"] = request_payer
    if optional_object_attributes is not None:
        input_["optional_object_attributes"] = optional_object_attributes

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output