1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package s3control
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	s3controlcust "github.com/aws/aws-sdk-go-v2/service/s3control/internal/customizations"
11	"github.com/aws/aws-sdk-go-v2/service/s3control/types"
12	smithy "github.com/aws/smithy-go"
13	"github.com/aws/smithy-go/middleware"
14	smithyhttp "github.com/aws/smithy-go/transport/http"
15	"strings"
16)
17
18// This operation gets an Amazon S3 on Outposts bucket's lifecycle configuration.
19// To get an S3 bucket's lifecycle configuration, see
20// GetBucketLifecycleConfiguration
21// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html)
22// in the Amazon Simple Storage Service API. Returns the lifecycle configuration
23// information set on the Outposts bucket. For more information, see Using Amazon
24// S3 on Outposts
25// (https://docs.aws.amazon.com/AmazonS3/latest/dev/S3onOutposts.html) and for
26// information about lifecycle configuration, see  Object Lifecycle Management
27// (https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html) in
28// Amazon Simple Storage Service Developer Guide. To use this operation, you must
29// have permission to perform the s3-outposts:GetLifecycleConfiguration action. The
30// Outposts bucket owner has this permission, by default. The bucket owner can
31// grant this permission to others. For more information about permissions, see
32// Permissions Related to Bucket Subresource Operations
33// (https://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources)
34// and Managing Access Permissions to Your Amazon S3 Resources
35// (https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-access-control.html). All
36// Amazon S3 on Outposts REST API requests for this action require an additional
37// parameter of x-amz-outpost-id to be passed with the request and an S3 on
38// Outposts endpoint hostname prefix instead of s3-control. For an example of the
39// request syntax for Amazon S3 on Outposts that uses the S3 on Outposts endpoint
40// hostname prefix and the x-amz-outpost-id derived using the access point ARN, see
41// the Examples
42// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_GetBucketLifecycleConfiguration.html#API_control_GetBucketLifecycleConfiguration_Examples)
43// section. GetBucketLifecycleConfiguration has the following special error:
44//
45// *
46// Error code: NoSuchLifecycleConfiguration
47//
48// * Description: The lifecycle
49// configuration does not exist.
50//
51// * HTTP Status Code: 404 Not Found
52//
53// * SOAP Fault
54// Code Prefix: Client
55//
56// The following actions are related to
57// GetBucketLifecycleConfiguration:
58//
59// * PutBucketLifecycleConfiguration
60// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_PutBucketLifecycleConfiguration.html)
61//
62// *
63// DeleteBucketLifecycleConfiguration
64// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_DeleteBucketLifecycleConfiguration.html)
65func (c *Client) GetBucketLifecycleConfiguration(ctx context.Context, params *GetBucketLifecycleConfigurationInput, optFns ...func(*Options)) (*GetBucketLifecycleConfigurationOutput, error) {
66	if params == nil {
67		params = &GetBucketLifecycleConfigurationInput{}
68	}
69
70	result, metadata, err := c.invokeOperation(ctx, "GetBucketLifecycleConfiguration", params, optFns, addOperationGetBucketLifecycleConfigurationMiddlewares)
71	if err != nil {
72		return nil, err
73	}
74
75	out := result.(*GetBucketLifecycleConfigurationOutput)
76	out.ResultMetadata = metadata
77	return out, nil
78}
79
80type GetBucketLifecycleConfigurationInput struct {
81
82	// The AWS account ID of the Outposts bucket.
83	//
84	// This member is required.
85	AccountId *string
86
87	// The Amazon Resource Name (ARN) of the bucket. For using this parameter with
88	// Amazon S3 on Outposts with the REST API, you must specify the name and the
89	// x-amz-outpost-id as well. For using this parameter with S3 on Outposts with the
90	// AWS SDK and CLI, you must specify the ARN of the bucket accessed in the format
91	// arn:aws:s3-outposts:::outpost//bucket/. For example, to access the bucket
92	// reports through outpost my-outpost owned by account 123456789012 in Region
93	// us-west-2, use the URL encoding of
94	// arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/bucket/reports.
95	// The value must be URL encoded.
96	//
97	// This member is required.
98	Bucket *string
99}
100
101type GetBucketLifecycleConfigurationOutput struct {
102
103	// Container for the lifecycle rule of the Outposts bucket.
104	Rules []types.LifecycleRule
105
106	// Metadata pertaining to the operation's result.
107	ResultMetadata middleware.Metadata
108}
109
110func addOperationGetBucketLifecycleConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) {
111	err = stack.Serialize.Add(&awsRestxml_serializeOpGetBucketLifecycleConfiguration{}, middleware.After)
112	if err != nil {
113		return err
114	}
115	err = stack.Deserialize.Add(&awsRestxml_deserializeOpGetBucketLifecycleConfiguration{}, middleware.After)
116	if err != nil {
117		return err
118	}
119	if err = addSetLoggerMiddleware(stack, options); err != nil {
120		return err
121	}
122	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addResolveEndpointMiddleware(stack, options); err != nil {
129		return err
130	}
131	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
132		return err
133	}
134	if err = addRetryMiddlewares(stack, options); err != nil {
135		return err
136	}
137	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
141		return err
142	}
143	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
144		return err
145	}
146	if err = addClientUserAgent(stack); err != nil {
147		return err
148	}
149	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
150		return err
151	}
152	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
153		return err
154	}
155	if err = addEndpointPrefix_opGetBucketLifecycleConfigurationMiddleware(stack); err != nil {
156		return err
157	}
158	if err = addOpGetBucketLifecycleConfigurationValidationMiddleware(stack); err != nil {
159		return err
160	}
161	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBucketLifecycleConfiguration(options.Region), middleware.Before); err != nil {
162		return err
163	}
164	if err = addMetadataRetrieverMiddleware(stack); err != nil {
165		return err
166	}
167	if err = addGetBucketLifecycleConfigurationUpdateEndpoint(stack, options); err != nil {
168		return err
169	}
170	if err = addResponseErrorMiddleware(stack); err != nil {
171		return err
172	}
173	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
174		return err
175	}
176	if err = addRequestResponseLogging(stack, options); err != nil {
177		return err
178	}
179	return nil
180}
181
182type endpointPrefix_opGetBucketLifecycleConfigurationMiddleware struct {
183}
184
185func (*endpointPrefix_opGetBucketLifecycleConfigurationMiddleware) ID() string {
186	return "EndpointHostPrefix"
187}
188
189func (m *endpointPrefix_opGetBucketLifecycleConfigurationMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
190	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
191) {
192	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
193		return next.HandleSerialize(ctx, in)
194	}
195
196	req, ok := in.Request.(*smithyhttp.Request)
197	if !ok {
198		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
199	}
200
201	input, ok := in.Parameters.(*GetBucketLifecycleConfigurationInput)
202	if !ok {
203		return out, metadata, fmt.Errorf("unknown input type %T", in.Parameters)
204	}
205
206	var prefix strings.Builder
207	if input.AccountId == nil {
208		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so may not be nil")}
209	} else if !smithyhttp.ValidHostLabel(*input.AccountId) {
210		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so must match \"[a-zA-Z0-9-]{1,63}\", but was \"%s\"", *input.AccountId)}
211	} else {
212		prefix.WriteString(*input.AccountId)
213	}
214	prefix.WriteString(".")
215	req.URL.Host = prefix.String() + req.URL.Host
216
217	return next.HandleSerialize(ctx, in)
218}
219func addEndpointPrefix_opGetBucketLifecycleConfigurationMiddleware(stack *middleware.Stack) error {
220	return stack.Serialize.Insert(&endpointPrefix_opGetBucketLifecycleConfigurationMiddleware{}, `OperationSerializer`, middleware.After)
221}
222
223func newServiceMetadataMiddleware_opGetBucketLifecycleConfiguration(region string) *awsmiddleware.RegisterServiceMetadata {
224	return &awsmiddleware.RegisterServiceMetadata{
225		Region:        region,
226		ServiceID:     ServiceID,
227		SigningName:   "s3",
228		OperationName: "GetBucketLifecycleConfiguration",
229	}
230}
231
232func copyGetBucketLifecycleConfigurationInputForUpdateEndpoint(params interface{}) (interface{}, error) {
233	input, ok := params.(*GetBucketLifecycleConfigurationInput)
234	if !ok {
235		return nil, fmt.Errorf("expect *GetBucketLifecycleConfigurationInput type, got %T", params)
236	}
237	cpy := *input
238	return &cpy, nil
239}
240func getGetBucketLifecycleConfigurationARNMember(input interface{}) (*string, bool) {
241	in := input.(*GetBucketLifecycleConfigurationInput)
242	if in.Bucket == nil {
243		return nil, false
244	}
245	return in.Bucket, true
246}
247func setGetBucketLifecycleConfigurationARNMember(input interface{}, v string) error {
248	in := input.(*GetBucketLifecycleConfigurationInput)
249	in.Bucket = &v
250	return nil
251}
252func backFillGetBucketLifecycleConfigurationAccountID(input interface{}, v string) error {
253	in := input.(*GetBucketLifecycleConfigurationInput)
254	if in.AccountId != nil {
255		if !strings.EqualFold(*in.AccountId, v) {
256			return fmt.Errorf("error backfilling account id")
257		}
258		return nil
259	}
260	in.AccountId = &v
261	return nil
262}
263func addGetBucketLifecycleConfigurationUpdateEndpoint(stack *middleware.Stack, options Options) error {
264	return s3controlcust.UpdateEndpoint(stack, s3controlcust.UpdateEndpointOptions{
265		Accessor: s3controlcust.UpdateEndpointParameterAccessor{GetARNInput: getGetBucketLifecycleConfigurationARNMember,
266			BackfillAccountID: backFillGetBucketLifecycleConfigurationAccountID,
267			GetOutpostIDInput: nopGetOutpostIDFromInput,
268			UpdateARNField:    setGetBucketLifecycleConfigurationARNMember,
269			CopyInput:         copyGetBucketLifecycleConfigurationInputForUpdateEndpoint,
270		},
271		EndpointResolver:        options.EndpointResolver,
272		EndpointResolverOptions: options.EndpointOptions,
273		UseDualstack:            options.UseDualstack,
274		UseARNRegion:            options.UseARNRegion,
275	})
276}
277