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// Gets a list of Amazon S3 Storage Lens configurations. For more information about
19// S3 Storage Lens, see Working with Amazon S3 Storage Lens
20// (https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonS3/latest/dev/storage_lens.html)
21// in the Amazon Simple Storage Service Developer Guide. To use this action, you
22// must have permission to perform the s3:ListStorageLensConfigurations action. For
23// more information, see Setting permissions to use Amazon S3 Storage Lens
24// (https://docs.aws.amazon.com/AmazonS3/latest/dev/storage_lens.html#storage_lens_IAM)
25// in the Amazon Simple Storage Service Developer Guide.
26func (c *Client) ListStorageLensConfigurations(ctx context.Context, params *ListStorageLensConfigurationsInput, optFns ...func(*Options)) (*ListStorageLensConfigurationsOutput, error) {
27	if params == nil {
28		params = &ListStorageLensConfigurationsInput{}
29	}
30
31	result, metadata, err := c.invokeOperation(ctx, "ListStorageLensConfigurations", params, optFns, addOperationListStorageLensConfigurationsMiddlewares)
32	if err != nil {
33		return nil, err
34	}
35
36	out := result.(*ListStorageLensConfigurationsOutput)
37	out.ResultMetadata = metadata
38	return out, nil
39}
40
41type ListStorageLensConfigurationsInput struct {
42
43	// The account ID of the requester.
44	//
45	// This member is required.
46	AccountId *string
47
48	// A pagination token to request the next page of results.
49	NextToken *string
50}
51
52type ListStorageLensConfigurationsOutput struct {
53
54	// If the request produced more than the maximum number of S3 Storage Lens
55	// configuration results, you can pass this value into a subsequent request to
56	// retrieve the next page of results.
57	NextToken *string
58
59	// A list of S3 Storage Lens configurations.
60	StorageLensConfigurationList []types.ListStorageLensConfigurationEntry
61
62	// Metadata pertaining to the operation's result.
63	ResultMetadata middleware.Metadata
64}
65
66func addOperationListStorageLensConfigurationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
67	err = stack.Serialize.Add(&awsRestxml_serializeOpListStorageLensConfigurations{}, middleware.After)
68	if err != nil {
69		return err
70	}
71	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListStorageLensConfigurations{}, middleware.After)
72	if err != nil {
73		return err
74	}
75	if err = addSetLoggerMiddleware(stack, options); err != nil {
76		return err
77	}
78	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
79		return err
80	}
81	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
82		return err
83	}
84	if err = addResolveEndpointMiddleware(stack, options); err != nil {
85		return err
86	}
87	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
88		return err
89	}
90	if err = addRetryMiddlewares(stack, options); err != nil {
91		return err
92	}
93	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
94		return err
95	}
96	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
97		return err
98	}
99	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
100		return err
101	}
102	if err = addClientUserAgent(stack); err != nil {
103		return err
104	}
105	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
106		return err
107	}
108	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
109		return err
110	}
111	if err = addEndpointPrefix_opListStorageLensConfigurationsMiddleware(stack); err != nil {
112		return err
113	}
114	if err = addOpListStorageLensConfigurationsValidationMiddleware(stack); err != nil {
115		return err
116	}
117	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListStorageLensConfigurations(options.Region), middleware.Before); err != nil {
118		return err
119	}
120	if err = addMetadataRetrieverMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addListStorageLensConfigurationsUpdateEndpoint(stack, options); err != nil {
124		return err
125	}
126	if err = addResponseErrorMiddleware(stack); err != nil {
127		return err
128	}
129	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addRequestResponseLogging(stack, options); err != nil {
133		return err
134	}
135	return nil
136}
137
138type endpointPrefix_opListStorageLensConfigurationsMiddleware struct {
139}
140
141func (*endpointPrefix_opListStorageLensConfigurationsMiddleware) ID() string {
142	return "EndpointHostPrefix"
143}
144
145func (m *endpointPrefix_opListStorageLensConfigurationsMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
146	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
147) {
148	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
149		return next.HandleSerialize(ctx, in)
150	}
151
152	req, ok := in.Request.(*smithyhttp.Request)
153	if !ok {
154		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
155	}
156
157	input, ok := in.Parameters.(*ListStorageLensConfigurationsInput)
158	if !ok {
159		return out, metadata, fmt.Errorf("unknown input type %T", in.Parameters)
160	}
161
162	var prefix strings.Builder
163	if input.AccountId == nil {
164		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so may not be nil")}
165	} else if !smithyhttp.ValidHostLabel(*input.AccountId) {
166		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)}
167	} else {
168		prefix.WriteString(*input.AccountId)
169	}
170	prefix.WriteString(".")
171	req.URL.Host = prefix.String() + req.URL.Host
172
173	return next.HandleSerialize(ctx, in)
174}
175func addEndpointPrefix_opListStorageLensConfigurationsMiddleware(stack *middleware.Stack) error {
176	return stack.Serialize.Insert(&endpointPrefix_opListStorageLensConfigurationsMiddleware{}, `OperationSerializer`, middleware.After)
177}
178
179func newServiceMetadataMiddleware_opListStorageLensConfigurations(region string) *awsmiddleware.RegisterServiceMetadata {
180	return &awsmiddleware.RegisterServiceMetadata{
181		Region:        region,
182		ServiceID:     ServiceID,
183		SigningName:   "s3",
184		OperationName: "ListStorageLensConfigurations",
185	}
186}
187
188func copyListStorageLensConfigurationsInputForUpdateEndpoint(params interface{}) (interface{}, error) {
189	input, ok := params.(*ListStorageLensConfigurationsInput)
190	if !ok {
191		return nil, fmt.Errorf("expect *ListStorageLensConfigurationsInput type, got %T", params)
192	}
193	cpy := *input
194	return &cpy, nil
195}
196func backFillListStorageLensConfigurationsAccountID(input interface{}, v string) error {
197	in := input.(*ListStorageLensConfigurationsInput)
198	if in.AccountId != nil {
199		if !strings.EqualFold(*in.AccountId, v) {
200			return fmt.Errorf("error backfilling account id")
201		}
202		return nil
203	}
204	in.AccountId = &v
205	return nil
206}
207func addListStorageLensConfigurationsUpdateEndpoint(stack *middleware.Stack, options Options) error {
208	return s3controlcust.UpdateEndpoint(stack, s3controlcust.UpdateEndpointOptions{
209		Accessor: s3controlcust.UpdateEndpointParameterAccessor{GetARNInput: nopGetARNAccessor,
210			BackfillAccountID: nopBackfillAccountIDAccessor,
211			GetOutpostIDInput: nopGetOutpostIDFromInput,
212			UpdateARNField:    nopSetARNAccessor,
213			CopyInput:         copyListStorageLensConfigurationsInputForUpdateEndpoint,
214		},
215		EndpointResolver:        options.EndpointResolver,
216		EndpointResolverOptions: options.EndpointOptions,
217		UseDualstack:            options.UseDualstack,
218		UseARNRegion:            options.UseARNRegion,
219	})
220}
221