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 description for the specified stack; if no stack name was specified, 16// then it returns the description for all the stacks created. If the stack does 17// not exist, an AmazonCloudFormationException is returned. 18func (c *Client) DescribeStacks(ctx context.Context, params *DescribeStacksInput, optFns ...func(*Options)) (*DescribeStacksOutput, error) { 19 if params == nil { 20 params = &DescribeStacksInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "DescribeStacks", params, optFns, addOperationDescribeStacksMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*DescribeStacksOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33// The input for DescribeStacks action. 34type DescribeStacksInput struct { 35 36 // A string that identifies the next page of stacks that you want to retrieve. 37 NextToken *string 38 39 // The name or the unique stack ID that is associated with the stack, which are not 40 // always interchangeable: 41 // 42 // * Running stacks: You can specify either the stack's 43 // name or its unique stack ID. 44 // 45 // * Deleted stacks: You must specify the unique 46 // stack ID. 47 // 48 // Default: There is no default value. 49 StackName *string 50} 51 52// The output for a DescribeStacks action. 53type DescribeStacksOutput struct { 54 55 // If the output exceeds 1 MB in size, a string that identifies the next page of 56 // stacks. If no additional page exists, this value is null. 57 NextToken *string 58 59 // A list of stack structures. 60 Stacks []types.Stack 61 62 // Metadata pertaining to the operation's result. 63 ResultMetadata middleware.Metadata 64} 65 66func addOperationDescribeStacksMiddlewares(stack *middleware.Stack, options Options) (err error) { 67 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeStacks{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeStacks{}, 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_opDescribeStacks(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// DescribeStacksAPIClient is a client that implements the DescribeStacks 127// operation. 128type DescribeStacksAPIClient interface { 129 DescribeStacks(context.Context, *DescribeStacksInput, ...func(*Options)) (*DescribeStacksOutput, error) 130} 131 132var _ DescribeStacksAPIClient = (*Client)(nil) 133 134// DescribeStacksPaginatorOptions is the paginator options for DescribeStacks 135type DescribeStacksPaginatorOptions struct { 136 // Set to true if pagination should stop if the service returns a pagination token 137 // that matches the most recent token provided to the service. 138 StopOnDuplicateToken bool 139} 140 141// DescribeStacksPaginator is a paginator for DescribeStacks 142type DescribeStacksPaginator struct { 143 options DescribeStacksPaginatorOptions 144 client DescribeStacksAPIClient 145 params *DescribeStacksInput 146 nextToken *string 147 firstPage bool 148} 149 150// NewDescribeStacksPaginator returns a new DescribeStacksPaginator 151func NewDescribeStacksPaginator(client DescribeStacksAPIClient, params *DescribeStacksInput, optFns ...func(*DescribeStacksPaginatorOptions)) *DescribeStacksPaginator { 152 options := DescribeStacksPaginatorOptions{} 153 154 for _, fn := range optFns { 155 fn(&options) 156 } 157 158 if params == nil { 159 params = &DescribeStacksInput{} 160 } 161 162 return &DescribeStacksPaginator{ 163 options: options, 164 client: client, 165 params: params, 166 firstPage: true, 167 } 168} 169 170// HasMorePages returns a boolean indicating whether more pages are available 171func (p *DescribeStacksPaginator) HasMorePages() bool { 172 return p.firstPage || p.nextToken != nil 173} 174 175// NextPage retrieves the next DescribeStacks page. 176func (p *DescribeStacksPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeStacksOutput, error) { 177 if !p.HasMorePages() { 178 return nil, fmt.Errorf("no more pages available") 179 } 180 181 params := *p.params 182 params.NextToken = p.nextToken 183 184 result, err := p.client.DescribeStacks(ctx, ¶ms, optFns...) 185 if err != nil { 186 return nil, err 187 } 188 p.firstPage = false 189 190 prevToken := p.nextToken 191 p.nextToken = result.NextToken 192 193 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 194 p.nextToken = nil 195 } 196 197 return result, nil 198} 199 200func newServiceMetadataMiddleware_opDescribeStacks(region string) *awsmiddleware.RegisterServiceMetadata { 201 return &awsmiddleware.RegisterServiceMetadata{ 202 Region: region, 203 ServiceID: ServiceID, 204 SigningName: "cloudformation", 205 OperationName: "DescribeStacks", 206 } 207} 208