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 notebook instance lifestyle configurations created with the
17// CreateNotebookInstanceLifecycleConfig API.
18func (c *Client) ListNotebookInstanceLifecycleConfigs(ctx context.Context, params *ListNotebookInstanceLifecycleConfigsInput, optFns ...func(*Options)) (*ListNotebookInstanceLifecycleConfigsOutput, error) {
19	if params == nil {
20		params = &ListNotebookInstanceLifecycleConfigsInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "ListNotebookInstanceLifecycleConfigs", params, optFns, c.addOperationListNotebookInstanceLifecycleConfigsMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*ListNotebookInstanceLifecycleConfigsOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33type ListNotebookInstanceLifecycleConfigsInput struct {
34
35	// A filter that returns only lifecycle configurations that were created after the
36	// specified time (timestamp).
37	CreationTimeAfter *time.Time
38
39	// A filter that returns only lifecycle configurations that were created before the
40	// specified time (timestamp).
41	CreationTimeBefore *time.Time
42
43	// A filter that returns only lifecycle configurations that were modified after the
44	// specified time (timestamp).
45	LastModifiedTimeAfter *time.Time
46
47	// A filter that returns only lifecycle configurations that were modified before
48	// the specified time (timestamp).
49	LastModifiedTimeBefore *time.Time
50
51	// The maximum number of lifecycle configurations to return in the response.
52	MaxResults *int32
53
54	// A string in the lifecycle configuration name. This filter returns only lifecycle
55	// configurations whose name contains the specified string.
56	NameContains *string
57
58	// If the result of a ListNotebookInstanceLifecycleConfigs request was truncated,
59	// the response includes a NextToken. To get the next set of lifecycle
60	// configurations, use the token in the next request.
61	NextToken *string
62
63	// Sorts the list of results. The default is CreationTime.
64	SortBy types.NotebookInstanceLifecycleConfigSortKey
65
66	// The sort order for results.
67	SortOrder types.NotebookInstanceLifecycleConfigSortOrder
68
69	noSmithyDocumentSerde
70}
71
72type ListNotebookInstanceLifecycleConfigsOutput struct {
73
74	// If the response is truncated, Amazon SageMaker returns this token. To get the
75	// next set of lifecycle configurations, use it in the next request.
76	NextToken *string
77
78	// An array of NotebookInstanceLifecycleConfiguration objects, each listing a
79	// lifecycle configuration.
80	NotebookInstanceLifecycleConfigs []types.NotebookInstanceLifecycleConfigSummary
81
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84
85	noSmithyDocumentSerde
86}
87
88func (c *Client) addOperationListNotebookInstanceLifecycleConfigsMiddlewares(stack *middleware.Stack, options Options) (err error) {
89	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListNotebookInstanceLifecycleConfigs{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListNotebookInstanceLifecycleConfigs{}, middleware.After)
94	if err != nil {
95		return err
96	}
97	if err = addSetLoggerMiddleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addResolveEndpointMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
110		return err
111	}
112	if err = addRetryMiddlewares(stack, options); err != nil {
113		return err
114	}
115	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
122		return err
123	}
124	if err = addClientUserAgent(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListNotebookInstanceLifecycleConfigs(options.Region), middleware.Before); err != nil {
134		return err
135	}
136	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addResponseErrorMiddleware(stack); err != nil {
140		return err
141	}
142	if err = addRequestResponseLogging(stack, options); err != nil {
143		return err
144	}
145	return nil
146}
147
148// ListNotebookInstanceLifecycleConfigsAPIClient is a client that implements the
149// ListNotebookInstanceLifecycleConfigs operation.
150type ListNotebookInstanceLifecycleConfigsAPIClient interface {
151	ListNotebookInstanceLifecycleConfigs(context.Context, *ListNotebookInstanceLifecycleConfigsInput, ...func(*Options)) (*ListNotebookInstanceLifecycleConfigsOutput, error)
152}
153
154var _ ListNotebookInstanceLifecycleConfigsAPIClient = (*Client)(nil)
155
156// ListNotebookInstanceLifecycleConfigsPaginatorOptions is the paginator options
157// for ListNotebookInstanceLifecycleConfigs
158type ListNotebookInstanceLifecycleConfigsPaginatorOptions struct {
159	// The maximum number of lifecycle configurations to return in the response.
160	Limit int32
161
162	// Set to true if pagination should stop if the service returns a pagination token
163	// that matches the most recent token provided to the service.
164	StopOnDuplicateToken bool
165}
166
167// ListNotebookInstanceLifecycleConfigsPaginator is a paginator for
168// ListNotebookInstanceLifecycleConfigs
169type ListNotebookInstanceLifecycleConfigsPaginator struct {
170	options   ListNotebookInstanceLifecycleConfigsPaginatorOptions
171	client    ListNotebookInstanceLifecycleConfigsAPIClient
172	params    *ListNotebookInstanceLifecycleConfigsInput
173	nextToken *string
174	firstPage bool
175}
176
177// NewListNotebookInstanceLifecycleConfigsPaginator returns a new
178// ListNotebookInstanceLifecycleConfigsPaginator
179func NewListNotebookInstanceLifecycleConfigsPaginator(client ListNotebookInstanceLifecycleConfigsAPIClient, params *ListNotebookInstanceLifecycleConfigsInput, optFns ...func(*ListNotebookInstanceLifecycleConfigsPaginatorOptions)) *ListNotebookInstanceLifecycleConfigsPaginator {
180	if params == nil {
181		params = &ListNotebookInstanceLifecycleConfigsInput{}
182	}
183
184	options := ListNotebookInstanceLifecycleConfigsPaginatorOptions{}
185	if params.MaxResults != nil {
186		options.Limit = *params.MaxResults
187	}
188
189	for _, fn := range optFns {
190		fn(&options)
191	}
192
193	return &ListNotebookInstanceLifecycleConfigsPaginator{
194		options:   options,
195		client:    client,
196		params:    params,
197		firstPage: true,
198	}
199}
200
201// HasMorePages returns a boolean indicating whether more pages are available
202func (p *ListNotebookInstanceLifecycleConfigsPaginator) HasMorePages() bool {
203	return p.firstPage || p.nextToken != nil
204}
205
206// NextPage retrieves the next ListNotebookInstanceLifecycleConfigs page.
207func (p *ListNotebookInstanceLifecycleConfigsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListNotebookInstanceLifecycleConfigsOutput, error) {
208	if !p.HasMorePages() {
209		return nil, fmt.Errorf("no more pages available")
210	}
211
212	params := *p.params
213	params.NextToken = p.nextToken
214
215	var limit *int32
216	if p.options.Limit > 0 {
217		limit = &p.options.Limit
218	}
219	params.MaxResults = limit
220
221	result, err := p.client.ListNotebookInstanceLifecycleConfigs(ctx, &params, optFns...)
222	if err != nil {
223		return nil, err
224	}
225	p.firstPage = false
226
227	prevToken := p.nextToken
228	p.nextToken = result.NextToken
229
230	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
231		p.nextToken = nil
232	}
233
234	return result, nil
235}
236
237func newServiceMetadataMiddleware_opListNotebookInstanceLifecycleConfigs(region string) *awsmiddleware.RegisterServiceMetadata {
238	return &awsmiddleware.RegisterServiceMetadata{
239		Region:        region,
240		ServiceID:     ServiceID,
241		SigningName:   "sagemaker",
242		OperationName: "ListNotebookInstanceLifecycleConfigs",
243	}
244}
245