1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package budgets
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/budgets/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Describes all of the budget actions for an account.
16func (c *Client) DescribeBudgetActionsForAccount(ctx context.Context, params *DescribeBudgetActionsForAccountInput, optFns ...func(*Options)) (*DescribeBudgetActionsForAccountOutput, error) {
17	if params == nil {
18		params = &DescribeBudgetActionsForAccountInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "DescribeBudgetActionsForAccount", params, optFns, c.addOperationDescribeBudgetActionsForAccountMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*DescribeBudgetActionsForAccountOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type DescribeBudgetActionsForAccountInput struct {
32
33	// The account ID of the user. It should be a 12-digit number.
34	//
35	// This member is required.
36	AccountId *string
37
38	// An integer that represents how many entries a paginated response contains. The
39	// maximum is 100.
40	MaxResults *int32
41
42	// A generic string.
43	NextToken *string
44
45	noSmithyDocumentSerde
46}
47
48type DescribeBudgetActionsForAccountOutput struct {
49
50	// A list of the budget action resources information.
51	//
52	// This member is required.
53	Actions []types.Action
54
55	// A generic string.
56	NextToken *string
57
58	// Metadata pertaining to the operation's result.
59	ResultMetadata middleware.Metadata
60
61	noSmithyDocumentSerde
62}
63
64func (c *Client) addOperationDescribeBudgetActionsForAccountMiddlewares(stack *middleware.Stack, options Options) (err error) {
65	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeBudgetActionsForAccount{}, middleware.After)
66	if err != nil {
67		return err
68	}
69	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeBudgetActionsForAccount{}, middleware.After)
70	if err != nil {
71		return err
72	}
73	if err = addSetLoggerMiddleware(stack, options); err != nil {
74		return err
75	}
76	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
77		return err
78	}
79	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
80		return err
81	}
82	if err = addResolveEndpointMiddleware(stack, options); err != nil {
83		return err
84	}
85	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
86		return err
87	}
88	if err = addRetryMiddlewares(stack, options); err != nil {
89		return err
90	}
91	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
95		return err
96	}
97	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
98		return err
99	}
100	if err = addClientUserAgent(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
104		return err
105	}
106	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
107		return err
108	}
109	if err = addOpDescribeBudgetActionsForAccountValidationMiddleware(stack); err != nil {
110		return err
111	}
112	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeBudgetActionsForAccount(options.Region), middleware.Before); err != nil {
113		return err
114	}
115	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addResponseErrorMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addRequestResponseLogging(stack, options); err != nil {
122		return err
123	}
124	return nil
125}
126
127// DescribeBudgetActionsForAccountAPIClient is a client that implements the
128// DescribeBudgetActionsForAccount operation.
129type DescribeBudgetActionsForAccountAPIClient interface {
130	DescribeBudgetActionsForAccount(context.Context, *DescribeBudgetActionsForAccountInput, ...func(*Options)) (*DescribeBudgetActionsForAccountOutput, error)
131}
132
133var _ DescribeBudgetActionsForAccountAPIClient = (*Client)(nil)
134
135// DescribeBudgetActionsForAccountPaginatorOptions is the paginator options for
136// DescribeBudgetActionsForAccount
137type DescribeBudgetActionsForAccountPaginatorOptions struct {
138	// An integer that represents how many entries a paginated response contains. The
139	// maximum is 100.
140	Limit int32
141
142	// Set to true if pagination should stop if the service returns a pagination token
143	// that matches the most recent token provided to the service.
144	StopOnDuplicateToken bool
145}
146
147// DescribeBudgetActionsForAccountPaginator is a paginator for
148// DescribeBudgetActionsForAccount
149type DescribeBudgetActionsForAccountPaginator struct {
150	options   DescribeBudgetActionsForAccountPaginatorOptions
151	client    DescribeBudgetActionsForAccountAPIClient
152	params    *DescribeBudgetActionsForAccountInput
153	nextToken *string
154	firstPage bool
155}
156
157// NewDescribeBudgetActionsForAccountPaginator returns a new
158// DescribeBudgetActionsForAccountPaginator
159func NewDescribeBudgetActionsForAccountPaginator(client DescribeBudgetActionsForAccountAPIClient, params *DescribeBudgetActionsForAccountInput, optFns ...func(*DescribeBudgetActionsForAccountPaginatorOptions)) *DescribeBudgetActionsForAccountPaginator {
160	if params == nil {
161		params = &DescribeBudgetActionsForAccountInput{}
162	}
163
164	options := DescribeBudgetActionsForAccountPaginatorOptions{}
165	if params.MaxResults != nil {
166		options.Limit = *params.MaxResults
167	}
168
169	for _, fn := range optFns {
170		fn(&options)
171	}
172
173	return &DescribeBudgetActionsForAccountPaginator{
174		options:   options,
175		client:    client,
176		params:    params,
177		firstPage: true,
178	}
179}
180
181// HasMorePages returns a boolean indicating whether more pages are available
182func (p *DescribeBudgetActionsForAccountPaginator) HasMorePages() bool {
183	return p.firstPage || p.nextToken != nil
184}
185
186// NextPage retrieves the next DescribeBudgetActionsForAccount page.
187func (p *DescribeBudgetActionsForAccountPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeBudgetActionsForAccountOutput, error) {
188	if !p.HasMorePages() {
189		return nil, fmt.Errorf("no more pages available")
190	}
191
192	params := *p.params
193	params.NextToken = p.nextToken
194
195	var limit *int32
196	if p.options.Limit > 0 {
197		limit = &p.options.Limit
198	}
199	params.MaxResults = limit
200
201	result, err := p.client.DescribeBudgetActionsForAccount(ctx, &params, optFns...)
202	if err != nil {
203		return nil, err
204	}
205	p.firstPage = false
206
207	prevToken := p.nextToken
208	p.nextToken = result.NextToken
209
210	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
211		p.nextToken = nil
212	}
213
214	return result, nil
215}
216
217func newServiceMetadataMiddleware_opDescribeBudgetActionsForAccount(region string) *awsmiddleware.RegisterServiceMetadata {
218	return &awsmiddleware.RegisterServiceMetadata{
219		Region:        region,
220		ServiceID:     ServiceID,
221		SigningName:   "budgets",
222		OperationName: "DescribeBudgetActionsForAccount",
223	}
224}
225