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