1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package s3 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 s3cust "github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations" 10 "github.com/aws/aws-sdk-go-v2/service/s3/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Sets the supplied tag-set to an object that already exists in a bucket. A tag is 16// a key-value pair. You can associate tags with an object by sending a PUT request 17// against the tagging subresource that is associated with the object. You can 18// retrieve tags by sending a GET request. For more information, see 19// GetObjectTagging 20// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html). For 21// tagging-related restrictions related to characters and encodings, see Tag 22// Restrictions 23// (https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/allocation-tag-restrictions.html). 24// Note that Amazon S3 limits the maximum number of tags to 10 tags per object. To 25// use this operation, you must have permission to perform the s3:PutObjectTagging 26// action. By default, the bucket owner has this permission and can grant this 27// permission to others. To put tags of any other version, use the versionId query 28// parameter. You also need permission for the s3:PutObjectVersionTagging action. 29// For information about the Amazon S3 object tagging feature, see Object Tagging 30// (https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html). Special 31// Errors 32// 33// * Code: InvalidTagError 34// 35// * Cause: The tag provided was not a valid tag. 36// This error can occur if the tag did not pass input validation. For more 37// information, see Object Tagging 38// (https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html). 39// 40// * Code: 41// MalformedXMLError 42// 43// * Cause: The XML provided does not match the schema. 44// 45// * Code: 46// OperationAbortedError 47// 48// * Cause: A conflicting conditional action is currently in 49// progress against this resource. Please try again. 50// 51// * Code: InternalError 52// 53// * 54// Cause: The service was unable to apply the provided tag to the object. 55// 56// Related 57// Resources 58// 59// * GetObjectTagging 60// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html) 61// 62// * 63// DeleteObjectTagging 64// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjectTagging.html) 65func (c *Client) PutObjectTagging(ctx context.Context, params *PutObjectTaggingInput, optFns ...func(*Options)) (*PutObjectTaggingOutput, error) { 66 if params == nil { 67 params = &PutObjectTaggingInput{} 68 } 69 70 result, metadata, err := c.invokeOperation(ctx, "PutObjectTagging", params, optFns, addOperationPutObjectTaggingMiddlewares) 71 if err != nil { 72 return nil, err 73 } 74 75 out := result.(*PutObjectTaggingOutput) 76 out.ResultMetadata = metadata 77 return out, nil 78} 79 80type PutObjectTaggingInput struct { 81 82 // The bucket name containing the object. When using this action with an access 83 // point, you must direct requests to the access point hostname. The access point 84 // hostname takes the form 85 // AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this 86 // action with an access point through the AWS SDKs, you provide the access point 87 // ARN in place of the bucket name. For more information about access point ARNs, 88 // see Using Access Points 89 // (https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html) 90 // in the Amazon S3 User Guide. When using this action with Amazon S3 on Outposts, 91 // you must direct requests to the S3 on Outposts hostname. The S3 on Outposts 92 // hostname takes the form 93 // AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using 94 // this action using S3 on Outposts through the AWS SDKs, you provide the Outposts 95 // bucket ARN in place of the bucket name. For more information about S3 on 96 // Outposts ARNs, see Using S3 on Outposts 97 // (https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html) in the 98 // Amazon S3 User Guide. 99 // 100 // This member is required. 101 Bucket *string 102 103 // Name of the object key. 104 // 105 // This member is required. 106 Key *string 107 108 // Container for the TagSet and Tag elements 109 // 110 // This member is required. 111 Tagging *types.Tagging 112 113 // The MD5 hash for the request body. For requests made using the AWS Command Line 114 // Interface (CLI) or AWS SDKs, this field is calculated automatically. 115 ContentMD5 *string 116 117 // The account ID of the expected bucket owner. If the bucket is owned by a 118 // different account, the request will fail with an HTTP 403 (Access Denied) error. 119 ExpectedBucketOwner *string 120 121 // Confirms that the requester knows that they will be charged for the request. 122 // Bucket owners need not specify this parameter in their requests. For information 123 // about downloading objects from requester pays buckets, see Downloading Objects 124 // in Requestor Pays Buckets 125 // (https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html) 126 // in the Amazon S3 Developer Guide. 127 RequestPayer types.RequestPayer 128 129 // The versionId of the object that the tag-set will be added to. 130 VersionId *string 131} 132 133type PutObjectTaggingOutput struct { 134 135 // The versionId of the object the tag-set was added to. 136 VersionId *string 137 138 // Metadata pertaining to the operation's result. 139 ResultMetadata middleware.Metadata 140} 141 142func addOperationPutObjectTaggingMiddlewares(stack *middleware.Stack, options Options) (err error) { 143 err = stack.Serialize.Add(&awsRestxml_serializeOpPutObjectTagging{}, middleware.After) 144 if err != nil { 145 return err 146 } 147 err = stack.Deserialize.Add(&awsRestxml_deserializeOpPutObjectTagging{}, middleware.After) 148 if err != nil { 149 return err 150 } 151 if err = addSetLoggerMiddleware(stack, options); err != nil { 152 return err 153 } 154 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 155 return err 156 } 157 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 158 return err 159 } 160 if err = addResolveEndpointMiddleware(stack, options); err != nil { 161 return err 162 } 163 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 164 return err 165 } 166 if err = addRetryMiddlewares(stack, options); err != nil { 167 return err 168 } 169 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 170 return err 171 } 172 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 173 return err 174 } 175 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 176 return err 177 } 178 if err = addClientUserAgent(stack); err != nil { 179 return err 180 } 181 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 182 return err 183 } 184 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 185 return err 186 } 187 if err = addOpPutObjectTaggingValidationMiddleware(stack); err != nil { 188 return err 189 } 190 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutObjectTagging(options.Region), middleware.Before); err != nil { 191 return err 192 } 193 if err = addMetadataRetrieverMiddleware(stack); err != nil { 194 return err 195 } 196 if err = addPutObjectTaggingUpdateEndpoint(stack, options); err != nil { 197 return err 198 } 199 if err = addResponseErrorMiddleware(stack); err != nil { 200 return err 201 } 202 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 203 return err 204 } 205 if err = disableAcceptEncodingGzip(stack); err != nil { 206 return err 207 } 208 if err = addRequestResponseLogging(stack, options); err != nil { 209 return err 210 } 211 if err = smithyhttp.AddContentChecksumMiddleware(stack); err != nil { 212 return err 213 } 214 return nil 215} 216 217func newServiceMetadataMiddleware_opPutObjectTagging(region string) *awsmiddleware.RegisterServiceMetadata { 218 return &awsmiddleware.RegisterServiceMetadata{ 219 Region: region, 220 ServiceID: ServiceID, 221 SigningName: "s3", 222 OperationName: "PutObjectTagging", 223 } 224} 225 226// getPutObjectTaggingBucketMember returns a pointer to string denoting a provided 227// bucket member valueand a boolean indicating if the input has a modeled bucket 228// name, 229func getPutObjectTaggingBucketMember(input interface{}) (*string, bool) { 230 in := input.(*PutObjectTaggingInput) 231 if in.Bucket == nil { 232 return nil, false 233 } 234 return in.Bucket, true 235} 236func addPutObjectTaggingUpdateEndpoint(stack *middleware.Stack, options Options) error { 237 return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{ 238 Accessor: s3cust.UpdateEndpointParameterAccessor{ 239 GetBucketFromInput: getPutObjectTaggingBucketMember, 240 }, 241 UsePathStyle: options.UsePathStyle, 242 UseAccelerate: options.UseAccelerate, 243 SupportsAccelerate: true, 244 TargetS3ObjectLambda: false, 245 EndpointResolver: options.EndpointResolver, 246 EndpointResolverOptions: options.EndpointOptions, 247 UseDualstack: options.UseDualstack, 248 UseARNRegion: options.UseARNRegion, 249 }) 250} 251