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// Bucket lifecycle configuration now supports specifying a lifecycle rule using an
16// object key name prefix, one or more object tags, or a combination of both.
17// Accordingly, this section describes the latest API. The response describes the
18// new filter element that you can use to specify a filter to select a subset of
19// objects to which the rule applies. If you are using a previous version of the
20// lifecycle configuration, it still works. For the earlier action, see
21// GetBucketLifecycle
22// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycle.html).
23// Returns the lifecycle configuration information set on the bucket. For
24// information about lifecycle configuration, see Object Lifecycle Management
25// (https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html). To
26// use this operation, you must have permission to perform the
27// s3:GetLifecycleConfiguration action. The bucket owner has this permission, by
28// default. The bucket owner can grant this permission to others. For more
29// information about permissions, see Permissions Related to Bucket Subresource
30// Operations
31// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources)
32// and Managing Access Permissions to Your Amazon S3 Resources
33// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html).
34// GetBucketLifecycleConfiguration has the following special error:
35//
36// * Error code:
37// NoSuchLifecycleConfiguration
38//
39// * Description: The lifecycle configuration does
40// not exist.
41//
42// * HTTP Status Code: 404 Not Found
43//
44// * SOAP Fault Code Prefix:
45// Client
46//
47// The following operations are related to
48// GetBucketLifecycleConfiguration:
49//
50// * GetBucketLifecycle
51// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycle.html)
52//
53// *
54// PutBucketLifecycle
55// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html)
56//
57// *
58// DeleteBucketLifecycle
59// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html)
60func (c *Client) GetBucketLifecycleConfiguration(ctx context.Context, params *GetBucketLifecycleConfigurationInput, optFns ...func(*Options)) (*GetBucketLifecycleConfigurationOutput, error) {
61	if params == nil {
62		params = &GetBucketLifecycleConfigurationInput{}
63	}
64
65	result, metadata, err := c.invokeOperation(ctx, "GetBucketLifecycleConfiguration", params, optFns, addOperationGetBucketLifecycleConfigurationMiddlewares)
66	if err != nil {
67		return nil, err
68	}
69
70	out := result.(*GetBucketLifecycleConfigurationOutput)
71	out.ResultMetadata = metadata
72	return out, nil
73}
74
75type GetBucketLifecycleConfigurationInput struct {
76
77	// The name of the bucket for which to get the lifecycle information.
78	//
79	// This member is required.
80	Bucket *string
81
82	// The account ID of the expected bucket owner. If the bucket is owned by a
83	// different account, the request will fail with an HTTP 403 (Access Denied) error.
84	ExpectedBucketOwner *string
85}
86
87type GetBucketLifecycleConfigurationOutput struct {
88
89	// Container for a lifecycle rule.
90	Rules []types.LifecycleRule
91
92	// Metadata pertaining to the operation's result.
93	ResultMetadata middleware.Metadata
94}
95
96func addOperationGetBucketLifecycleConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) {
97	err = stack.Serialize.Add(&awsRestxml_serializeOpGetBucketLifecycleConfiguration{}, middleware.After)
98	if err != nil {
99		return err
100	}
101	err = stack.Deserialize.Add(&awsRestxml_deserializeOpGetBucketLifecycleConfiguration{}, middleware.After)
102	if err != nil {
103		return err
104	}
105	if err = addSetLoggerMiddleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
112		return err
113	}
114	if err = addResolveEndpointMiddleware(stack, options); err != nil {
115		return err
116	}
117	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
118		return err
119	}
120	if err = addRetryMiddlewares(stack, options); err != nil {
121		return err
122	}
123	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
124		return err
125	}
126	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
127		return err
128	}
129	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
130		return err
131	}
132	if err = addClientUserAgent(stack); err != nil {
133		return err
134	}
135	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
136		return err
137	}
138	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
139		return err
140	}
141	if err = addOpGetBucketLifecycleConfigurationValidationMiddleware(stack); err != nil {
142		return err
143	}
144	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBucketLifecycleConfiguration(options.Region), middleware.Before); err != nil {
145		return err
146	}
147	if err = addMetadataRetrieverMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addGetBucketLifecycleConfigurationUpdateEndpoint(stack, options); err != nil {
151		return err
152	}
153	if err = addResponseErrorMiddleware(stack); err != nil {
154		return err
155	}
156	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
157		return err
158	}
159	if err = disableAcceptEncodingGzip(stack); err != nil {
160		return err
161	}
162	if err = addRequestResponseLogging(stack, options); err != nil {
163		return err
164	}
165	return nil
166}
167
168func newServiceMetadataMiddleware_opGetBucketLifecycleConfiguration(region string) *awsmiddleware.RegisterServiceMetadata {
169	return &awsmiddleware.RegisterServiceMetadata{
170		Region:        region,
171		ServiceID:     ServiceID,
172		SigningName:   "s3",
173		OperationName: "GetBucketLifecycleConfiguration",
174	}
175}
176
177// getGetBucketLifecycleConfigurationBucketMember returns a pointer to string
178// denoting a provided bucket member valueand a boolean indicating if the input has
179// a modeled bucket name,
180func getGetBucketLifecycleConfigurationBucketMember(input interface{}) (*string, bool) {
181	in := input.(*GetBucketLifecycleConfigurationInput)
182	if in.Bucket == nil {
183		return nil, false
184	}
185	return in.Bucket, true
186}
187func addGetBucketLifecycleConfigurationUpdateEndpoint(stack *middleware.Stack, options Options) error {
188	return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{
189		Accessor: s3cust.UpdateEndpointParameterAccessor{
190			GetBucketFromInput: getGetBucketLifecycleConfigurationBucketMember,
191		},
192		UsePathStyle:            options.UsePathStyle,
193		UseAccelerate:           options.UseAccelerate,
194		SupportsAccelerate:      true,
195		TargetS3ObjectLambda:    false,
196		EndpointResolver:        options.EndpointResolver,
197		EndpointResolverOptions: options.EndpointOptions,
198		UseDualstack:            options.UseDualstack,
199		UseARNRegion:            options.UseARNRegion,
200	})
201}
202