1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package sagemaker
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/sagemaker/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13	"time"
14)
15
16// Lists the actions in your account and their properties.
17func (c *Client) ListActions(ctx context.Context, params *ListActionsInput, optFns ...func(*Options)) (*ListActionsOutput, error) {
18	if params == nil {
19		params = &ListActionsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "ListActions", params, optFns, c.addOperationListActionsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*ListActionsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type ListActionsInput struct {
33
34	// A filter that returns only actions of the specified type.
35	ActionType *string
36
37	// A filter that returns only actions created on or after the specified time.
38	CreatedAfter *time.Time
39
40	// A filter that returns only actions created on or before the specified time.
41	CreatedBefore *time.Time
42
43	// The maximum number of actions to return in the response. The default value is
44	// 10.
45	MaxResults *int32
46
47	// If the previous call to ListActions didn't return the full set of actions, the
48	// call returns a token for getting the next set of actions.
49	NextToken *string
50
51	// The property used to sort results. The default value is CreationTime.
52	SortBy types.SortActionsBy
53
54	// The sort order. The default value is Descending.
55	SortOrder types.SortOrder
56
57	// A filter that returns only actions with the specified source URI.
58	SourceUri *string
59
60	noSmithyDocumentSerde
61}
62
63type ListActionsOutput struct {
64
65	// A list of actions and their properties.
66	ActionSummaries []types.ActionSummary
67
68	// A token for getting the next set of actions, if there are any.
69	NextToken *string
70
71	// Metadata pertaining to the operation's result.
72	ResultMetadata middleware.Metadata
73
74	noSmithyDocumentSerde
75}
76
77func (c *Client) addOperationListActionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
78	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListActions{}, middleware.After)
79	if err != nil {
80		return err
81	}
82	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListActions{}, middleware.After)
83	if err != nil {
84		return err
85	}
86	if err = addSetLoggerMiddleware(stack, options); err != nil {
87		return err
88	}
89	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
90		return err
91	}
92	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
93		return err
94	}
95	if err = addResolveEndpointMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
99		return err
100	}
101	if err = addRetryMiddlewares(stack, options); err != nil {
102		return err
103	}
104	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
105		return err
106	}
107	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
108		return err
109	}
110	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
111		return err
112	}
113	if err = addClientUserAgent(stack); err != nil {
114		return err
115	}
116	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
117		return err
118	}
119	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
120		return err
121	}
122	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListActions(options.Region), middleware.Before); err != nil {
123		return err
124	}
125	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addResponseErrorMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addRequestResponseLogging(stack, options); err != nil {
132		return err
133	}
134	return nil
135}
136
137// ListActionsAPIClient is a client that implements the ListActions operation.
138type ListActionsAPIClient interface {
139	ListActions(context.Context, *ListActionsInput, ...func(*Options)) (*ListActionsOutput, error)
140}
141
142var _ ListActionsAPIClient = (*Client)(nil)
143
144// ListActionsPaginatorOptions is the paginator options for ListActions
145type ListActionsPaginatorOptions struct {
146	// The maximum number of actions to return in the response. The default value is
147	// 10.
148	Limit int32
149
150	// Set to true if pagination should stop if the service returns a pagination token
151	// that matches the most recent token provided to the service.
152	StopOnDuplicateToken bool
153}
154
155// ListActionsPaginator is a paginator for ListActions
156type ListActionsPaginator struct {
157	options   ListActionsPaginatorOptions
158	client    ListActionsAPIClient
159	params    *ListActionsInput
160	nextToken *string
161	firstPage bool
162}
163
164// NewListActionsPaginator returns a new ListActionsPaginator
165func NewListActionsPaginator(client ListActionsAPIClient, params *ListActionsInput, optFns ...func(*ListActionsPaginatorOptions)) *ListActionsPaginator {
166	if params == nil {
167		params = &ListActionsInput{}
168	}
169
170	options := ListActionsPaginatorOptions{}
171	if params.MaxResults != nil {
172		options.Limit = *params.MaxResults
173	}
174
175	for _, fn := range optFns {
176		fn(&options)
177	}
178
179	return &ListActionsPaginator{
180		options:   options,
181		client:    client,
182		params:    params,
183		firstPage: true,
184	}
185}
186
187// HasMorePages returns a boolean indicating whether more pages are available
188func (p *ListActionsPaginator) HasMorePages() bool {
189	return p.firstPage || p.nextToken != nil
190}
191
192// NextPage retrieves the next ListActions page.
193func (p *ListActionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListActionsOutput, error) {
194	if !p.HasMorePages() {
195		return nil, fmt.Errorf("no more pages available")
196	}
197
198	params := *p.params
199	params.NextToken = p.nextToken
200
201	var limit *int32
202	if p.options.Limit > 0 {
203		limit = &p.options.Limit
204	}
205	params.MaxResults = limit
206
207	result, err := p.client.ListActions(ctx, &params, optFns...)
208	if err != nil {
209		return nil, err
210	}
211	p.firstPage = false
212
213	prevToken := p.nextToken
214	p.nextToken = result.NextToken
215
216	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
217		p.nextToken = nil
218	}
219
220	return result, nil
221}
222
223func newServiceMetadataMiddleware_opListActions(region string) *awsmiddleware.RegisterServiceMetadata {
224	return &awsmiddleware.RegisterServiceMetadata{
225		Region:        region,
226		ServiceID:     ServiceID,
227		SigningName:   "sagemaker",
228		OperationName: "ListActions",
229	}
230}
231