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// This implementation of the PUT operation adds an inventory configuration 16// (identified by the inventory ID) to the bucket. You can have up to 1,000 17// inventory configurations per bucket. Amazon S3 inventory generates inventories 18// of the objects in the bucket on a daily or weekly basis, and the results are 19// published to a flat file. The bucket that is inventoried is called the source 20// bucket, and the bucket where the inventory flat file is stored is called the 21// destination bucket. The destination bucket must be in the same AWS Region as the 22// source bucket. When you configure an inventory for a source bucket, you specify 23// the destination bucket where you want the inventory to be stored, and whether to 24// generate the inventory daily or weekly. You can also configure what object 25// metadata to include and whether to inventory all object versions or only current 26// versions. For more information, see Amazon S3 Inventory 27// (https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html) in the 28// Amazon Simple Storage Service Developer Guide. You must create a bucket policy 29// on the destination bucket to grant permissions to Amazon S3 to write objects to 30// the bucket in the defined location. For an example policy, see Granting 31// Permissions for Amazon S3 Inventory and Storage Class Analysis 32// (https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-9). 33// To use this operation, you must have permissions to perform the 34// s3:PutInventoryConfiguration action. The bucket owner has this permission by 35// default and can grant this permission to others. For more information about 36// permissions, see Permissions Related to Bucket Subresource Operations 37// (https://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources) 38// and Managing Access Permissions to Your Amazon S3 Resources 39// (https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-access-control.html) in the 40// Amazon Simple Storage Service Developer Guide. Special Errors 41// 42// * HTTP 400 Bad 43// Request Error 44// 45// * Code: InvalidArgument 46// 47// * Cause: Invalid Argument 48// 49// * HTTP 400 50// Bad Request Error 51// 52// * Code: TooManyConfigurations 53// 54// * Cause: You are attempting to 55// create a new configuration but have already reached the 1,000-configuration 56// limit. 57// 58// * HTTP 403 Forbidden Error 59// 60// * Code: AccessDenied 61// 62// * Cause: You are not 63// the owner of the specified bucket, or you do not have the 64// s3:PutInventoryConfiguration bucket permission to set the configuration on the 65// bucket. 66// 67// Related Resources 68// 69// * GetBucketInventoryConfiguration 70// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html) 71// 72// * 73// DeleteBucketInventoryConfiguration 74// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html) 75// 76// * 77// ListBucketInventoryConfigurations 78// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html) 79func (c *Client) PutBucketInventoryConfiguration(ctx context.Context, params *PutBucketInventoryConfigurationInput, optFns ...func(*Options)) (*PutBucketInventoryConfigurationOutput, error) { 80 if params == nil { 81 params = &PutBucketInventoryConfigurationInput{} 82 } 83 84 result, metadata, err := c.invokeOperation(ctx, "PutBucketInventoryConfiguration", params, optFns, addOperationPutBucketInventoryConfigurationMiddlewares) 85 if err != nil { 86 return nil, err 87 } 88 89 out := result.(*PutBucketInventoryConfigurationOutput) 90 out.ResultMetadata = metadata 91 return out, nil 92} 93 94type PutBucketInventoryConfigurationInput struct { 95 96 // The name of the bucket where the inventory configuration will be stored. 97 // 98 // This member is required. 99 Bucket *string 100 101 // The ID used to identify the inventory configuration. 102 // 103 // This member is required. 104 Id *string 105 106 // Specifies the inventory configuration. 107 // 108 // This member is required. 109 InventoryConfiguration *types.InventoryConfiguration 110 111 // The account id of the expected bucket owner. If the bucket is owned by a 112 // different account, the request will fail with an HTTP 403 (Access Denied) error. 113 ExpectedBucketOwner *string 114} 115 116type PutBucketInventoryConfigurationOutput struct { 117 // Metadata pertaining to the operation's result. 118 ResultMetadata middleware.Metadata 119} 120 121func addOperationPutBucketInventoryConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) { 122 err = stack.Serialize.Add(&awsRestxml_serializeOpPutBucketInventoryConfiguration{}, middleware.After) 123 if err != nil { 124 return err 125 } 126 err = stack.Deserialize.Add(&awsRestxml_deserializeOpPutBucketInventoryConfiguration{}, middleware.After) 127 if err != nil { 128 return err 129 } 130 if err = addSetLoggerMiddleware(stack, options); err != nil { 131 return err 132 } 133 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 134 return err 135 } 136 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 137 return err 138 } 139 if err = addResolveEndpointMiddleware(stack, options); err != nil { 140 return err 141 } 142 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 143 return err 144 } 145 if err = addRetryMiddlewares(stack, options); err != nil { 146 return err 147 } 148 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 149 return err 150 } 151 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 152 return err 153 } 154 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 155 return err 156 } 157 if err = addClientUserAgent(stack); err != nil { 158 return err 159 } 160 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 161 return err 162 } 163 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addOpPutBucketInventoryConfigurationValidationMiddleware(stack); err != nil { 167 return err 168 } 169 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutBucketInventoryConfiguration(options.Region), middleware.Before); err != nil { 170 return err 171 } 172 if err = addMetadataRetrieverMiddleware(stack); err != nil { 173 return err 174 } 175 if err = addPutBucketInventoryConfigurationUpdateEndpoint(stack, options); err != nil { 176 return err 177 } 178 if err = addResponseErrorMiddleware(stack); err != nil { 179 return err 180 } 181 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 182 return err 183 } 184 if err = disableAcceptEncodingGzip(stack); err != nil { 185 return err 186 } 187 if err = addRequestResponseLogging(stack, options); err != nil { 188 return err 189 } 190 return nil 191} 192 193func newServiceMetadataMiddleware_opPutBucketInventoryConfiguration(region string) *awsmiddleware.RegisterServiceMetadata { 194 return &awsmiddleware.RegisterServiceMetadata{ 195 Region: region, 196 ServiceID: ServiceID, 197 SigningName: "s3", 198 OperationName: "PutBucketInventoryConfiguration", 199 } 200} 201 202// getPutBucketInventoryConfigurationBucketMember returns a pointer to string 203// denoting a provided bucket member valueand a boolean indicating if the input has 204// a modeled bucket name, 205func getPutBucketInventoryConfigurationBucketMember(input interface{}) (*string, bool) { 206 in := input.(*PutBucketInventoryConfigurationInput) 207 if in.Bucket == nil { 208 return nil, false 209 } 210 return in.Bucket, true 211} 212func addPutBucketInventoryConfigurationUpdateEndpoint(stack *middleware.Stack, options Options) error { 213 return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{ 214 Accessor: s3cust.UpdateEndpointParameterAccessor{ 215 GetBucketFromInput: getPutBucketInventoryConfigurationBucketMember, 216 }, 217 UsePathStyle: options.UsePathStyle, 218 UseAccelerate: options.UseAccelerate, 219 SupportsAccelerate: true, 220 EndpointResolver: options.EndpointResolver, 221 EndpointResolverOptions: options.EndpointOptions, 222 UseDualstack: options.UseDualstack, 223 UseARNRegion: options.UseARNRegion, 224 }) 225} 226