1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudformation
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/cloudformation/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns summary information about stack sets that are associated with the user.
16func (c *Client) ListStackSets(ctx context.Context, params *ListStackSetsInput, optFns ...func(*Options)) (*ListStackSetsOutput, error) {
17	if params == nil {
18		params = &ListStackSetsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "ListStackSets", params, optFns, addOperationListStackSetsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*ListStackSetsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type ListStackSetsInput struct {
32
33	// The maximum number of results to be returned with a single call. If the number
34	// of available results exceeds this maximum, the response includes a NextToken
35	// value that you can assign to the NextToken request parameter to get the next set
36	// of results.
37	MaxResults *int32
38
39	// If the previous paginated request didn't return all of the remaining results,
40	// the response object's NextToken parameter value is set to a token. To retrieve
41	// the next set of results, call ListStackSets again and assign that token to the
42	// request object's NextToken parameter. If there are no remaining results, the
43	// previous response object's NextToken parameter is set to null.
44	NextToken *string
45
46	// The status of the stack sets that you want to get summary information about.
47	Status types.StackSetStatus
48}
49
50type ListStackSetsOutput struct {
51
52	// If the request doesn't return all of the remaining results, NextToken is set to
53	// a token. To retrieve the next set of results, call ListStackInstances again and
54	// assign that token to the request object's NextToken parameter. If the request
55	// returns all results, NextToken is set to null.
56	NextToken *string
57
58	// A list of StackSetSummary structures that contain information about the user's
59	// stack sets.
60	Summaries []types.StackSetSummary
61
62	// Metadata pertaining to the operation's result.
63	ResultMetadata middleware.Metadata
64}
65
66func addOperationListStackSetsMiddlewares(stack *middleware.Stack, options Options) (err error) {
67	err = stack.Serialize.Add(&awsAwsquery_serializeOpListStackSets{}, middleware.After)
68	if err != nil {
69		return err
70	}
71	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpListStackSets{}, 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 = stack.Initialize.Add(newServiceMetadataMiddleware_opListStackSets(options.Region), middleware.Before); err != nil {
112		return err
113	}
114	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
115		return err
116	}
117	if err = addResponseErrorMiddleware(stack); err != nil {
118		return err
119	}
120	if err = addRequestResponseLogging(stack, options); err != nil {
121		return err
122	}
123	return nil
124}
125
126// ListStackSetsAPIClient is a client that implements the ListStackSets operation.
127type ListStackSetsAPIClient interface {
128	ListStackSets(context.Context, *ListStackSetsInput, ...func(*Options)) (*ListStackSetsOutput, error)
129}
130
131var _ ListStackSetsAPIClient = (*Client)(nil)
132
133// ListStackSetsPaginatorOptions is the paginator options for ListStackSets
134type ListStackSetsPaginatorOptions struct {
135	// The maximum number of results to be returned with a single call. If the number
136	// of available results exceeds this maximum, the response includes a NextToken
137	// value that you can assign to the NextToken request parameter to get the next set
138	// of results.
139	Limit int32
140
141	// Set to true if pagination should stop if the service returns a pagination token
142	// that matches the most recent token provided to the service.
143	StopOnDuplicateToken bool
144}
145
146// ListStackSetsPaginator is a paginator for ListStackSets
147type ListStackSetsPaginator struct {
148	options   ListStackSetsPaginatorOptions
149	client    ListStackSetsAPIClient
150	params    *ListStackSetsInput
151	nextToken *string
152	firstPage bool
153}
154
155// NewListStackSetsPaginator returns a new ListStackSetsPaginator
156func NewListStackSetsPaginator(client ListStackSetsAPIClient, params *ListStackSetsInput, optFns ...func(*ListStackSetsPaginatorOptions)) *ListStackSetsPaginator {
157	options := ListStackSetsPaginatorOptions{}
158	if params.MaxResults != nil {
159		options.Limit = *params.MaxResults
160	}
161
162	for _, fn := range optFns {
163		fn(&options)
164	}
165
166	if params == nil {
167		params = &ListStackSetsInput{}
168	}
169
170	return &ListStackSetsPaginator{
171		options:   options,
172		client:    client,
173		params:    params,
174		firstPage: true,
175	}
176}
177
178// HasMorePages returns a boolean indicating whether more pages are available
179func (p *ListStackSetsPaginator) HasMorePages() bool {
180	return p.firstPage || p.nextToken != nil
181}
182
183// NextPage retrieves the next ListStackSets page.
184func (p *ListStackSetsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListStackSetsOutput, error) {
185	if !p.HasMorePages() {
186		return nil, fmt.Errorf("no more pages available")
187	}
188
189	params := *p.params
190	params.NextToken = p.nextToken
191
192	var limit *int32
193	if p.options.Limit > 0 {
194		limit = &p.options.Limit
195	}
196	params.MaxResults = limit
197
198	result, err := p.client.ListStackSets(ctx, &params, optFns...)
199	if err != nil {
200		return nil, err
201	}
202	p.firstPage = false
203
204	prevToken := p.nextToken
205	p.nextToken = result.NextToken
206
207	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
208		p.nextToken = nil
209	}
210
211	return result, nil
212}
213
214func newServiceMetadataMiddleware_opListStackSets(region string) *awsmiddleware.RegisterServiceMetadata {
215	return &awsmiddleware.RegisterServiceMetadata{
216		Region:        region,
217		ServiceID:     ServiceID,
218		SigningName:   "cloudformation",
219		OperationName: "ListStackSets",
220	}
221}
222