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