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 the summary information for stacks whose status matches the specified 16// StackStatusFilter. Summary information for stacks that have been deleted is kept 17// for 90 days after the stack is deleted. If no StackStatusFilter is specified, 18// summary information for all stacks is returned (including existing stacks and 19// stacks that have been deleted). 20func (c *Client) ListStacks(ctx context.Context, params *ListStacksInput, optFns ...func(*Options)) (*ListStacksOutput, error) { 21 if params == nil { 22 params = &ListStacksInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "ListStacks", params, optFns, addOperationListStacksMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*ListStacksOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33} 34 35// The input for ListStacks action. 36type ListStacksInput struct { 37 38 // A string that identifies the next page of stacks that you want to retrieve. 39 NextToken *string 40 41 // Stack status to use as a filter. Specify one or more stack status codes to list 42 // only stacks with the specified status codes. For a complete list of stack status 43 // codes, see the StackStatus parameter of the Stack data type. 44 StackStatusFilter []types.StackStatus 45} 46 47// The output for ListStacks action. 48type ListStacksOutput struct { 49 50 // If the output exceeds 1 MB in size, a string that identifies the next page of 51 // stacks. If no additional page exists, this value is null. 52 NextToken *string 53 54 // A list of StackSummary structures containing information about the specified 55 // stacks. 56 StackSummaries []types.StackSummary 57 58 // Metadata pertaining to the operation's result. 59 ResultMetadata middleware.Metadata 60} 61 62func addOperationListStacksMiddlewares(stack *middleware.Stack, options Options) (err error) { 63 err = stack.Serialize.Add(&awsAwsquery_serializeOpListStacks{}, middleware.After) 64 if err != nil { 65 return err 66 } 67 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpListStacks{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 if err = addSetLoggerMiddleware(stack, options); err != nil { 72 return err 73 } 74 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 75 return err 76 } 77 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 78 return err 79 } 80 if err = addResolveEndpointMiddleware(stack, options); err != nil { 81 return err 82 } 83 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 84 return err 85 } 86 if err = addRetryMiddlewares(stack, options); err != nil { 87 return err 88 } 89 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 96 return err 97 } 98 if err = addClientUserAgent(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 105 return err 106 } 107 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListStacks(options.Region), middleware.Before); err != nil { 108 return err 109 } 110 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResponseErrorMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addRequestResponseLogging(stack, options); err != nil { 117 return err 118 } 119 return nil 120} 121 122// ListStacksAPIClient is a client that implements the ListStacks operation. 123type ListStacksAPIClient interface { 124 ListStacks(context.Context, *ListStacksInput, ...func(*Options)) (*ListStacksOutput, error) 125} 126 127var _ ListStacksAPIClient = (*Client)(nil) 128 129// ListStacksPaginatorOptions is the paginator options for ListStacks 130type ListStacksPaginatorOptions struct { 131 // Set to true if pagination should stop if the service returns a pagination token 132 // that matches the most recent token provided to the service. 133 StopOnDuplicateToken bool 134} 135 136// ListStacksPaginator is a paginator for ListStacks 137type ListStacksPaginator struct { 138 options ListStacksPaginatorOptions 139 client ListStacksAPIClient 140 params *ListStacksInput 141 nextToken *string 142 firstPage bool 143} 144 145// NewListStacksPaginator returns a new ListStacksPaginator 146func NewListStacksPaginator(client ListStacksAPIClient, params *ListStacksInput, optFns ...func(*ListStacksPaginatorOptions)) *ListStacksPaginator { 147 if params == nil { 148 params = &ListStacksInput{} 149 } 150 151 options := ListStacksPaginatorOptions{} 152 153 for _, fn := range optFns { 154 fn(&options) 155 } 156 157 return &ListStacksPaginator{ 158 options: options, 159 client: client, 160 params: params, 161 firstPage: true, 162 } 163} 164 165// HasMorePages returns a boolean indicating whether more pages are available 166func (p *ListStacksPaginator) HasMorePages() bool { 167 return p.firstPage || p.nextToken != nil 168} 169 170// NextPage retrieves the next ListStacks page. 171func (p *ListStacksPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListStacksOutput, error) { 172 if !p.HasMorePages() { 173 return nil, fmt.Errorf("no more pages available") 174 } 175 176 params := *p.params 177 params.NextToken = p.nextToken 178 179 result, err := p.client.ListStacks(ctx, ¶ms, optFns...) 180 if err != nil { 181 return nil, err 182 } 183 p.firstPage = false 184 185 prevToken := p.nextToken 186 p.nextToken = result.NextToken 187 188 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 189 p.nextToken = nil 190 } 191 192 return result, nil 193} 194 195func newServiceMetadataMiddleware_opListStacks(region string) *awsmiddleware.RegisterServiceMetadata { 196 return &awsmiddleware.RegisterServiceMetadata{ 197 Region: region, 198 ServiceID: ServiceID, 199 SigningName: "cloudformation", 200 OperationName: "ListStacks", 201 } 202} 203