1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package fsx
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	"github.com/aws/aws-sdk-go-v2/service/fsx/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns the description of specific Amazon FSx file systems, if a FileSystemIds
16// value is provided for that file system. Otherwise, it returns descriptions of
17// all file systems owned by your AWS account in the AWS Region of the endpoint
18// that you're calling. When retrieving all file system descriptions, you can
19// optionally specify the MaxResults parameter to limit the number of descriptions
20// in a response. If more file system descriptions remain, Amazon FSx returns a
21// NextToken value in the response. In this case, send a later request with the
22// NextToken request parameter set to the value of NextToken from the last
23// response. This action is used in an iterative process to retrieve a list of your
24// file system descriptions. DescribeFileSystems is called first without a
25// NextTokenvalue. Then the action continues to be called with the NextToken
26// parameter set to the value of the last NextToken value until a response has no
27// NextToken. When using this action, keep the following in mind:
28//
29// * The
30// implementation might return fewer than MaxResults file system descriptions while
31// still including a NextToken value.
32//
33// * The order of file systems returned in the
34// response of one DescribeFileSystems call and the order of file systems returned
35// across the responses of a multicall iteration is unspecified.
36func (c *Client) DescribeFileSystems(ctx context.Context, params *DescribeFileSystemsInput, optFns ...func(*Options)) (*DescribeFileSystemsOutput, error) {
37	if params == nil {
38		params = &DescribeFileSystemsInput{}
39	}
40
41	result, metadata, err := c.invokeOperation(ctx, "DescribeFileSystems", params, optFns, addOperationDescribeFileSystemsMiddlewares)
42	if err != nil {
43		return nil, err
44	}
45
46	out := result.(*DescribeFileSystemsOutput)
47	out.ResultMetadata = metadata
48	return out, nil
49}
50
51// The request object for DescribeFileSystems operation.
52type DescribeFileSystemsInput struct {
53
54	// IDs of the file systems whose descriptions you want to retrieve (String).
55	FileSystemIds []string
56
57	// Maximum number of file systems to return in the response (integer). This
58	// parameter value must be greater than 0. The number of items that Amazon FSx
59	// returns is the minimum of the MaxResults parameter specified in the request and
60	// the service's internal maximum number of items per page.
61	MaxResults *int32
62
63	// Opaque pagination token returned from a previous DescribeFileSystems operation
64	// (String). If a token present, the action continues the list from where the
65	// returning call left off.
66	NextToken *string
67}
68
69// The response object for DescribeFileSystems operation.
70type DescribeFileSystemsOutput struct {
71
72	// An array of file system descriptions.
73	FileSystems []types.FileSystem
74
75	// Present if there are more file systems than returned in the response (String).
76	// You can use the NextToken value in the later request to fetch the descriptions.
77	NextToken *string
78
79	// Metadata pertaining to the operation's result.
80	ResultMetadata middleware.Metadata
81}
82
83func addOperationDescribeFileSystemsMiddlewares(stack *middleware.Stack, options Options) (err error) {
84	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeFileSystems{}, middleware.After)
85	if err != nil {
86		return err
87	}
88	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeFileSystems{}, middleware.After)
89	if err != nil {
90		return err
91	}
92	if err = addSetLoggerMiddleware(stack, options); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
96		return err
97	}
98	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
99		return err
100	}
101	if err = addResolveEndpointMiddleware(stack, options); err != nil {
102		return err
103	}
104	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
105		return err
106	}
107	if err = addRetryMiddlewares(stack, options); err != nil {
108		return err
109	}
110	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
111		return err
112	}
113	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
117		return err
118	}
119	if err = addClientUserAgent(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeFileSystems(options.Region), middleware.Before); err != nil {
129		return err
130	}
131	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
132		return err
133	}
134	if err = addResponseErrorMiddleware(stack); err != nil {
135		return err
136	}
137	if err = addRequestResponseLogging(stack, options); err != nil {
138		return err
139	}
140	return nil
141}
142
143// DescribeFileSystemsAPIClient is a client that implements the DescribeFileSystems
144// operation.
145type DescribeFileSystemsAPIClient interface {
146	DescribeFileSystems(context.Context, *DescribeFileSystemsInput, ...func(*Options)) (*DescribeFileSystemsOutput, error)
147}
148
149var _ DescribeFileSystemsAPIClient = (*Client)(nil)
150
151// DescribeFileSystemsPaginatorOptions is the paginator options for
152// DescribeFileSystems
153type DescribeFileSystemsPaginatorOptions struct {
154	// Maximum number of file systems to return in the response (integer). This
155	// parameter value must be greater than 0. The number of items that Amazon FSx
156	// returns is the minimum of the MaxResults parameter specified in the request and
157	// the service's internal maximum number of items per page.
158	Limit int32
159
160	// Set to true if pagination should stop if the service returns a pagination token
161	// that matches the most recent token provided to the service.
162	StopOnDuplicateToken bool
163}
164
165// DescribeFileSystemsPaginator is a paginator for DescribeFileSystems
166type DescribeFileSystemsPaginator struct {
167	options   DescribeFileSystemsPaginatorOptions
168	client    DescribeFileSystemsAPIClient
169	params    *DescribeFileSystemsInput
170	nextToken *string
171	firstPage bool
172}
173
174// NewDescribeFileSystemsPaginator returns a new DescribeFileSystemsPaginator
175func NewDescribeFileSystemsPaginator(client DescribeFileSystemsAPIClient, params *DescribeFileSystemsInput, optFns ...func(*DescribeFileSystemsPaginatorOptions)) *DescribeFileSystemsPaginator {
176	if params == nil {
177		params = &DescribeFileSystemsInput{}
178	}
179
180	options := DescribeFileSystemsPaginatorOptions{}
181	if params.MaxResults != nil {
182		options.Limit = *params.MaxResults
183	}
184
185	for _, fn := range optFns {
186		fn(&options)
187	}
188
189	return &DescribeFileSystemsPaginator{
190		options:   options,
191		client:    client,
192		params:    params,
193		firstPage: true,
194	}
195}
196
197// HasMorePages returns a boolean indicating whether more pages are available
198func (p *DescribeFileSystemsPaginator) HasMorePages() bool {
199	return p.firstPage || p.nextToken != nil
200}
201
202// NextPage retrieves the next DescribeFileSystems page.
203func (p *DescribeFileSystemsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeFileSystemsOutput, error) {
204	if !p.HasMorePages() {
205		return nil, fmt.Errorf("no more pages available")
206	}
207
208	params := *p.params
209	params.NextToken = p.nextToken
210
211	var limit *int32
212	if p.options.Limit > 0 {
213		limit = &p.options.Limit
214	}
215	params.MaxResults = limit
216
217	result, err := p.client.DescribeFileSystems(ctx, &params, optFns...)
218	if err != nil {
219		return nil, err
220	}
221	p.firstPage = false
222
223	prevToken := p.nextToken
224	p.nextToken = result.NextToken
225
226	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
227		p.nextToken = nil
228	}
229
230	return result, nil
231}
232
233func newServiceMetadataMiddleware_opDescribeFileSystems(region string) *awsmiddleware.RegisterServiceMetadata {
234	return &awsmiddleware.RegisterServiceMetadata{
235		Region:        region,
236		ServiceID:     ServiceID,
237		SigningName:   "fsx",
238		OperationName: "DescribeFileSystems",
239	}
240}
241