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// Returns metadata about all versions of the objects in a bucket. You can also use
16// request parameters as selection criteria to return metadata about a subset of
17// all the object versions. To use this operation, you must have permissions to
18// perform the s3:ListBucketVersions action. Be aware of the name difference. A 200
19// OK response can contain valid or invalid XML. Make sure to design your
20// application to parse the contents of the response and handle it appropriately.
21// To use this operation, you must have READ access to the bucket. This action is
22// not supported by Amazon S3 on Outposts. The following operations are related to
23// ListObjectVersions:
24//
25// * ListObjectsV2
26// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html)
27//
28// *
29// GetObject
30// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html)
31//
32// *
33// PutObject
34// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html)
35//
36// *
37// DeleteObject
38// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html)
39func (c *Client) ListObjectVersions(ctx context.Context, params *ListObjectVersionsInput, optFns ...func(*Options)) (*ListObjectVersionsOutput, error) {
40	if params == nil {
41		params = &ListObjectVersionsInput{}
42	}
43
44	result, metadata, err := c.invokeOperation(ctx, "ListObjectVersions", params, optFns, c.addOperationListObjectVersionsMiddlewares)
45	if err != nil {
46		return nil, err
47	}
48
49	out := result.(*ListObjectVersionsOutput)
50	out.ResultMetadata = metadata
51	return out, nil
52}
53
54type ListObjectVersionsInput struct {
55
56	// The bucket name that contains the objects.
57	//
58	// This member is required.
59	Bucket *string
60
61	// A delimiter is a character that you specify to group keys. All keys that contain
62	// the same string between the prefix and the first occurrence of the delimiter are
63	// grouped under a single result element in CommonPrefixes. These groups are
64	// counted as one result against the max-keys limitation. These keys are not
65	// returned elsewhere in the response.
66	Delimiter *string
67
68	// Requests Amazon S3 to encode the object keys in the response and specifies the
69	// encoding method to use. An object key may contain any Unicode character;
70	// however, XML 1.0 parser cannot parse some characters, such as characters with an
71	// ASCII value from 0 to 10. For characters that are not supported in XML 1.0, you
72	// can add this parameter to request that Amazon S3 encode the keys in the
73	// response.
74	EncodingType types.EncodingType
75
76	// The account ID of the expected bucket owner. If the bucket is owned by a
77	// different account, the request will fail with an HTTP 403 (Access Denied) error.
78	ExpectedBucketOwner *string
79
80	// Specifies the key to start with when listing objects in a bucket.
81	KeyMarker *string
82
83	// Sets the maximum number of keys returned in the response. By default the action
84	// returns up to 1,000 key names. The response might contain fewer keys but will
85	// never contain more. If additional keys satisfy the search criteria, but were not
86	// returned because max-keys was exceeded, the response contains true. To return
87	// the additional keys, see key-marker and version-id-marker.
88	MaxKeys int32
89
90	// Use this parameter to select only those keys that begin with the specified
91	// prefix. You can use prefixes to separate a bucket into different groupings of
92	// keys. (You can think of using prefix to make groups in the same way you'd use a
93	// folder in a file system.) You can use prefix with delimiter to roll up numerous
94	// objects into a single result under CommonPrefixes.
95	Prefix *string
96
97	// Specifies the object version you want to start listing from.
98	VersionIdMarker *string
99
100	noSmithyDocumentSerde
101}
102
103type ListObjectVersionsOutput struct {
104
105	// All of the keys rolled up into a common prefix count as a single return when
106	// calculating the number of returns.
107	CommonPrefixes []types.CommonPrefix
108
109	// Container for an object that is a delete marker.
110	DeleteMarkers []types.DeleteMarkerEntry
111
112	// The delimiter grouping the included keys. A delimiter is a character that you
113	// specify to group keys. All keys that contain the same string between the prefix
114	// and the first occurrence of the delimiter are grouped under a single result
115	// element in CommonPrefixes. These groups are counted as one result against the
116	// max-keys limitation. These keys are not returned elsewhere in the response.
117	Delimiter *string
118
119	// Encoding type used by Amazon S3 to encode object key names in the XML response.
120	// If you specify encoding-type request parameter, Amazon S3 includes this element
121	// in the response, and returns encoded key name values in the following response
122	// elements: KeyMarker, NextKeyMarker, Prefix, Key, and Delimiter.
123	EncodingType types.EncodingType
124
125	// A flag that indicates whether Amazon S3 returned all of the results that
126	// satisfied the search criteria. If your results were truncated, you can make a
127	// follow-up paginated request using the NextKeyMarker and NextVersionIdMarker
128	// response parameters as a starting place in another request to return the rest of
129	// the results.
130	IsTruncated bool
131
132	// Marks the last key returned in a truncated response.
133	KeyMarker *string
134
135	// Specifies the maximum number of objects to return.
136	MaxKeys int32
137
138	// The bucket name.
139	Name *string
140
141	// When the number of responses exceeds the value of MaxKeys, NextKeyMarker
142	// specifies the first key not returned that satisfies the search criteria. Use
143	// this value for the key-marker request parameter in a subsequent request.
144	NextKeyMarker *string
145
146	// When the number of responses exceeds the value of MaxKeys, NextVersionIdMarker
147	// specifies the first object version not returned that satisfies the search
148	// criteria. Use this value for the version-id-marker request parameter in a
149	// subsequent request.
150	NextVersionIdMarker *string
151
152	// Selects objects that start with the value supplied by this parameter.
153	Prefix *string
154
155	// Marks the last version of the key returned in a truncated response.
156	VersionIdMarker *string
157
158	// Container for version information.
159	Versions []types.ObjectVersion
160
161	// Metadata pertaining to the operation's result.
162	ResultMetadata middleware.Metadata
163
164	noSmithyDocumentSerde
165}
166
167func (c *Client) addOperationListObjectVersionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
168	err = stack.Serialize.Add(&awsRestxml_serializeOpListObjectVersions{}, middleware.After)
169	if err != nil {
170		return err
171	}
172	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListObjectVersions{}, middleware.After)
173	if err != nil {
174		return err
175	}
176	if err = addSetLoggerMiddleware(stack, options); err != nil {
177		return err
178	}
179	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
180		return err
181	}
182	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
183		return err
184	}
185	if err = addResolveEndpointMiddleware(stack, options); err != nil {
186		return err
187	}
188	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
189		return err
190	}
191	if err = addRetryMiddlewares(stack, options); err != nil {
192		return err
193	}
194	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
195		return err
196	}
197	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
198		return err
199	}
200	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
201		return err
202	}
203	if err = addClientUserAgent(stack); err != nil {
204		return err
205	}
206	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
207		return err
208	}
209	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
210		return err
211	}
212	if err = swapWithCustomHTTPSignerMiddleware(stack, options); err != nil {
213		return err
214	}
215	if err = addOpListObjectVersionsValidationMiddleware(stack); err != nil {
216		return err
217	}
218	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListObjectVersions(options.Region), middleware.Before); err != nil {
219		return err
220	}
221	if err = addMetadataRetrieverMiddleware(stack); err != nil {
222		return err
223	}
224	if err = addListObjectVersionsUpdateEndpoint(stack, options); err != nil {
225		return err
226	}
227	if err = addResponseErrorMiddleware(stack); err != nil {
228		return err
229	}
230	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
231		return err
232	}
233	if err = disableAcceptEncodingGzip(stack); err != nil {
234		return err
235	}
236	if err = addRequestResponseLogging(stack, options); err != nil {
237		return err
238	}
239	return nil
240}
241
242func newServiceMetadataMiddleware_opListObjectVersions(region string) *awsmiddleware.RegisterServiceMetadata {
243	return &awsmiddleware.RegisterServiceMetadata{
244		Region:        region,
245		ServiceID:     ServiceID,
246		SigningName:   "s3",
247		OperationName: "ListObjectVersions",
248	}
249}
250
251// getListObjectVersionsBucketMember returns a pointer to string denoting a
252// provided bucket member valueand a boolean indicating if the input has a modeled
253// bucket name,
254func getListObjectVersionsBucketMember(input interface{}) (*string, bool) {
255	in := input.(*ListObjectVersionsInput)
256	if in.Bucket == nil {
257		return nil, false
258	}
259	return in.Bucket, true
260}
261func addListObjectVersionsUpdateEndpoint(stack *middleware.Stack, options Options) error {
262	return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{
263		Accessor: s3cust.UpdateEndpointParameterAccessor{
264			GetBucketFromInput: getListObjectVersionsBucketMember,
265		},
266		UsePathStyle:                   options.UsePathStyle,
267		UseAccelerate:                  options.UseAccelerate,
268		SupportsAccelerate:             true,
269		TargetS3ObjectLambda:           false,
270		EndpointResolver:               options.EndpointResolver,
271		EndpointResolverOptions:        options.EndpointOptions,
272		UseDualstack:                   options.UseDualstack,
273		UseARNRegion:                   options.UseARNRegion,
274		DisableMultiRegionAccessPoints: options.DisableMultiRegionAccessPoints,
275	})
276}
277