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// Retrieves your account's AWS CloudFormation limits, such as the maximum number
16// of stacks that you can create in your account. For more information about
17// account limits, see AWS CloudFormation Limits
18// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html)
19// in the AWS CloudFormation User Guide.
20func (c *Client) DescribeAccountLimits(ctx context.Context, params *DescribeAccountLimitsInput, optFns ...func(*Options)) (*DescribeAccountLimitsOutput, error) {
21	if params == nil {
22		params = &DescribeAccountLimitsInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "DescribeAccountLimits", params, optFns, addOperationDescribeAccountLimitsMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*DescribeAccountLimitsOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35// The input for the DescribeAccountLimits action.
36type DescribeAccountLimitsInput struct {
37
38	// A string that identifies the next page of limits that you want to retrieve.
39	NextToken *string
40}
41
42// The output for the DescribeAccountLimits action.
43type DescribeAccountLimitsOutput struct {
44
45	// An account limit structure that contain a list of AWS CloudFormation account
46	// limits and their values.
47	AccountLimits []types.AccountLimit
48
49	// If the output exceeds 1 MB in size, a string that identifies the next page of
50	// limits. If no additional page exists, this value is null.
51	NextToken *string
52
53	// Metadata pertaining to the operation's result.
54	ResultMetadata middleware.Metadata
55}
56
57func addOperationDescribeAccountLimitsMiddlewares(stack *middleware.Stack, options Options) (err error) {
58	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeAccountLimits{}, middleware.After)
59	if err != nil {
60		return err
61	}
62	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeAccountLimits{}, middleware.After)
63	if err != nil {
64		return err
65	}
66	if err = addSetLoggerMiddleware(stack, options); err != nil {
67		return err
68	}
69	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
70		return err
71	}
72	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
73		return err
74	}
75	if err = addResolveEndpointMiddleware(stack, options); err != nil {
76		return err
77	}
78	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
79		return err
80	}
81	if err = addRetryMiddlewares(stack, options); err != nil {
82		return err
83	}
84	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
85		return err
86	}
87	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
91		return err
92	}
93	if err = addClientUserAgent(stack); err != nil {
94		return err
95	}
96	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
97		return err
98	}
99	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
100		return err
101	}
102	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeAccountLimits(options.Region), middleware.Before); err != nil {
103		return err
104	}
105	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
106		return err
107	}
108	if err = addResponseErrorMiddleware(stack); err != nil {
109		return err
110	}
111	if err = addRequestResponseLogging(stack, options); err != nil {
112		return err
113	}
114	return nil
115}
116
117// DescribeAccountLimitsAPIClient is a client that implements the
118// DescribeAccountLimits operation.
119type DescribeAccountLimitsAPIClient interface {
120	DescribeAccountLimits(context.Context, *DescribeAccountLimitsInput, ...func(*Options)) (*DescribeAccountLimitsOutput, error)
121}
122
123var _ DescribeAccountLimitsAPIClient = (*Client)(nil)
124
125// DescribeAccountLimitsPaginatorOptions is the paginator options for
126// DescribeAccountLimits
127type DescribeAccountLimitsPaginatorOptions struct {
128	// Set to true if pagination should stop if the service returns a pagination token
129	// that matches the most recent token provided to the service.
130	StopOnDuplicateToken bool
131}
132
133// DescribeAccountLimitsPaginator is a paginator for DescribeAccountLimits
134type DescribeAccountLimitsPaginator struct {
135	options   DescribeAccountLimitsPaginatorOptions
136	client    DescribeAccountLimitsAPIClient
137	params    *DescribeAccountLimitsInput
138	nextToken *string
139	firstPage bool
140}
141
142// NewDescribeAccountLimitsPaginator returns a new DescribeAccountLimitsPaginator
143func NewDescribeAccountLimitsPaginator(client DescribeAccountLimitsAPIClient, params *DescribeAccountLimitsInput, optFns ...func(*DescribeAccountLimitsPaginatorOptions)) *DescribeAccountLimitsPaginator {
144	options := DescribeAccountLimitsPaginatorOptions{}
145
146	for _, fn := range optFns {
147		fn(&options)
148	}
149
150	if params == nil {
151		params = &DescribeAccountLimitsInput{}
152	}
153
154	return &DescribeAccountLimitsPaginator{
155		options:   options,
156		client:    client,
157		params:    params,
158		firstPage: true,
159	}
160}
161
162// HasMorePages returns a boolean indicating whether more pages are available
163func (p *DescribeAccountLimitsPaginator) HasMorePages() bool {
164	return p.firstPage || p.nextToken != nil
165}
166
167// NextPage retrieves the next DescribeAccountLimits page.
168func (p *DescribeAccountLimitsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeAccountLimitsOutput, error) {
169	if !p.HasMorePages() {
170		return nil, fmt.Errorf("no more pages available")
171	}
172
173	params := *p.params
174	params.NextToken = p.nextToken
175
176	result, err := p.client.DescribeAccountLimits(ctx, &params, optFns...)
177	if err != nil {
178		return nil, err
179	}
180	p.firstPage = false
181
182	prevToken := p.nextToken
183	p.nextToken = result.NextToken
184
185	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
186		p.nextToken = nil
187	}
188
189	return result, nil
190}
191
192func newServiceMetadataMiddleware_opDescribeAccountLimits(region string) *awsmiddleware.RegisterServiceMetadata {
193	return &awsmiddleware.RegisterServiceMetadata{
194		Region:        region,
195		ServiceID:     ServiceID,
196		SigningName:   "cloudformation",
197		OperationName: "DescribeAccountLimits",
198	}
199}
200