Skip to content

delete_object_annotation

delete_object_annotation(
    bucket: BucketName,
    key: ObjectKey,
    annotation_name: AnnotationName,
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    version_id: Optional[ObjectVersionId] = None,
    request_payer: Optional[RequestPayer] = None,
    expected_bucket_owner: Optional[AccountId] = None,
    object_if_match: Optional[ObjectIfMatch] = None,
) -> DeleteObjectAnnotationOutput

Deletes a specific annotation from an Amazon S3 object. Use the x-amz-object-if-match header to perform a conditional delete that only succeeds if the object's ETag matches the provided value, preventing race conditions during concurrent updates.

Deleting an annotation is permanent. Annotations are not independently versioned, so there is no delete marker or way to recover a deleted annotation.

To use this operation, you must have the s3:DeleteObjectAnnotation permission. If the object is protected by Object Lock in governance mode, you must also include the x-amz-bypass-governance-retention header.

Annotations are not supported by the following features: S3 Inventory Reports, API Gateway, S3 Storage Lens, Amazon S3 File Gateway, Amazon FSx, S3 on Outposts, and S3 Express One Zone (directory buckets).

The following operations are related to DeleteObjectAnnotation:

Parameters:

  • bucket (BucketName) –

    The name of the bucket that contains the object.

  • key (ObjectKey) –

    The object key.

  • annotation_name (AnnotationName) –

    The name of the annotation to delete. Annotation names are UTF-8 encoded and cannot start with aws or s3 (case-insensitive).

    Length Constraints: Minimum length of 1. Maximum length of 512 bytes.

  • version_id (Optional[ObjectVersionId], default: None ) –

    The version ID of the object.

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

    The account ID of the expected bucket owner.

  • object_if_match (Optional[ObjectIfMatch], default: None ) –

    If specified, the operation only succeeds if the object's ETag matches the provided value.

Raises:

Source code in docs_src/capo_s3/_services/s3.py
def delete_object_annotation(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    key: "capo_s3.types.object_key.ObjectKey",
    annotation_name: "capo_s3.types.annotation_name.AnnotationName",
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    version_id: Optional["capo_s3.types.object_version_id.ObjectVersionId"] = None,
    request_payer: Optional["capo_s3.types.request_payer.RequestPayer"] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
    object_if_match: Optional["capo_s3.types.object_if_match.ObjectIfMatch"] = None,
) -> "capo_s3.types.delete_object_annotation_output.DeleteObjectAnnotationOutput":
    """<p>Deletes a specific annotation from an Amazon S3 object. Use the <code>x-amz-object-if-match</code> header to perform a conditional delete that only succeeds if the object's ETag matches the provided value, preventing race conditions during concurrent updates.</p> <p>Deleting an annotation is permanent. Annotations are not independently versioned, so there is no delete marker or way to recover a deleted annotation.</p> <p>To use this operation, you must have the <code>s3:DeleteObjectAnnotation</code> permission. If the object is protected by Object Lock in governance mode, you must also include the <code>x-amz-bypass-governance-retention</code> header.</p> <note> <p>Annotations are not supported by the following features: S3 Inventory Reports, API Gateway, S3 Storage Lens, Amazon S3 File Gateway, Amazon FSx, S3 on Outposts, and S3 Express One Zone (directory buckets).</p> </note> <p>The following operations are related to <code>DeleteObjectAnnotation</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectAnnotation.html">PutObjectAnnotation</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAnnotation.html">GetObjectAnnotation</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectAnnotations.html">ListObjectAnnotations</a> </p> </li> </ul>

    Args:
        bucket: <p>The name of the bucket that contains the object.</p>
        key: <p>The object key.</p>
        annotation_name: <p>The name of the annotation to delete. Annotation names are UTF-8 encoded and cannot start with <code>aws</code> or <code>s3</code> (case-insensitive).</p> <p>Length Constraints: Minimum length of 1. Maximum length of 512 bytes.</p>
        version_id: <p>The version ID of the object.</p>
        expected_bucket_owner: <p>The account ID of the expected bucket owner.</p>
        object_if_match: <p>If specified, the operation only succeeds if the object's ETag matches the provided value.</p>

    Raises:
        capo_s3.errors.no_such_bucket.NoSuchBucket: <p>The specified bucket does not exist.</p>
        capo_s3.errors.no_such_key.NoSuchKey: <p>The specified key does not exist.</p>
        capo_s3.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_s3.types.delete_object_annotation_request.DeleteObjectAnnotationRequest]",
    ) -> OperationResponse[
        "capo_s3.types.delete_object_annotation_output.DeleteObjectAnnotationOutput"
    ]:
        import capo_s3._operations.amazon_s3.delete_object_annotation

        output, http_response = (
            capo_s3._operations.amazon_s3.delete_object_annotation.delete_object_annotation(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteObjectAnnotation")
    )
    input_: capo_s3.types.delete_object_annotation_request.DeleteObjectAnnotationRequest = {
        "bucket": bucket,
        "key": key,
        "annotation_name": annotation_name,
    }
    if version_id is not None:
        input_["version_id"] = version_id
    if request_payer is not None:
        input_["request_payer"] = request_payer
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner
    if object_if_match is not None:
        input_["object_if_match"] = object_if_match

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output