// Code generated by smithy-go-codegen DO NOT EDIT.

package s3

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
	s3cust "github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations"
	"github.com/aws/aws-sdk-go-v2/service/s3/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// 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 :
//
// [PutObjectAnnotation]
//
// [GetObjectAnnotation]
//
// [ListObjectAnnotations]
//
// [GetObjectAnnotation]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAnnotation.html
// [ListObjectAnnotations]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectAnnotations.html
// [PutObjectAnnotation]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectAnnotation.html
func (c *Client) DeleteObjectAnnotation(ctx context.Context, params *DeleteObjectAnnotationInput, optFns ...func(*Options)) (*DeleteObjectAnnotationOutput, error) {
	if params == nil {
		params = &DeleteObjectAnnotationInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "DeleteObjectAnnotation", params, optFns, c.addOperationDeleteObjectAnnotationMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*DeleteObjectAnnotationOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type DeleteObjectAnnotationInput struct {

	// 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.
	//
	// This member is required.
	AnnotationName *string

	// The name of the bucket that contains the object.
	//
	// This member is required.
	Bucket *string

	// The object key.
	//
	// This member is required.
	Key *string

	// The account ID of the expected bucket owner.
	ExpectedBucketOwner *string

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

	// Confirms that the requester knows that they will be charged for the request.
	// Bucket owners need not specify this parameter in their requests. If either the
	// source or destination S3 bucket has Requester Pays enabled, the requester will
	// pay for the corresponding charges. For information about downloading objects
	// from Requester Pays buckets, see [Downloading Objects in Requester Pays Buckets]in the Amazon S3 User Guide.
	//
	// This functionality is not supported for directory buckets.
	//
	// [Downloading Objects in Requester Pays Buckets]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
	RequestPayer types.RequestPayer

	// The version ID of the object.
	VersionId *string

	noSmithyDocumentSerde
}

func (in *DeleteObjectAnnotationInput) bindEndpointParams(p *EndpointParameters) {

	p.Bucket = in.Bucket

}

type DeleteObjectAnnotationOutput struct {

	// The version ID of the object that the annotation was deleted from.
	ObjectVersionId *string

	// If present, indicates that the requester was successfully charged for the
	// request. For more information, see [Using Requester Pays buckets for storage transfers and usage]in the Amazon Simple Storage Service user
	// guide.
	//
	// This functionality is not supported for directory buckets.
	//
	// [Using Requester Pays buckets for storage transfers and usage]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/RequesterPaysBuckets.html
	RequestCharged types.RequestCharged

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationDeleteObjectAnnotationMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestxml_serializeOpDeleteObjectAnnotation{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestxml_deserializeOpDeleteObjectAnnotation{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addPutBucketContextMiddleware(stack); err != nil {
		return err
	}
	if err = addIsExpressUserAgent(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpDeleteObjectAnnotationValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteObjectAnnotation"), middleware.Before); err != nil {
		return err
	}
	if err = addMetadataRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addDeleteObjectAnnotationUpdateEndpoint(stack, options); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
		return err
	}
	if err = disableAcceptEncodingGzip(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addSerializeImmutableHostnameBucketMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}

func (v *DeleteObjectAnnotationInput) bucket() (string, bool) {
	if v.Bucket == nil {
		return "", false
	}
	return *v.Bucket, true
}

// getDeleteObjectAnnotationBucketMember returns a pointer to string denoting a
// provided bucket member valueand a boolean indicating if the input has a modeled
// bucket name,
func getDeleteObjectAnnotationBucketMember(input interface{}) (*string, bool) {
	in := input.(*DeleteObjectAnnotationInput)
	if in.Bucket == nil {
		return nil, false
	}
	return in.Bucket, true
}
func addDeleteObjectAnnotationUpdateEndpoint(stack *middleware.Stack, options Options) error {
	return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{
		Accessor: s3cust.UpdateEndpointParameterAccessor{
			GetBucketFromInput: getDeleteObjectAnnotationBucketMember,
		},
		UsePathStyle:                   options.UsePathStyle,
		UseAccelerate:                  options.UseAccelerate,
		SupportsAccelerate:             true,
		TargetS3ObjectLambda:           false,
		EndpointResolver:               options.EndpointResolver,
		EndpointResolverOptions:        options.EndpointOptions,
		UseARNRegion:                   options.UseARNRegion,
		DisableMultiRegionAccessPoints: options.DisableMultiRegionAccessPoints,
	})
}
