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, 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
70type ListNotebookInstanceLifecycleConfigsOutput struct {
71
72	// If the response is truncated, Amazon SageMaker returns this token. To get the
73	// next set of lifecycle configurations, use it in the next request.
74	NextToken *string
75
76	// An array of NotebookInstanceLifecycleConfiguration objects, each listing a
77	// lifecycle configuration.
78	NotebookInstanceLifecycleConfigs []types.NotebookInstanceLifecycleConfigSummary
79
80	// Metadata pertaining to the operation's result.
81	ResultMetadata middleware.Metadata
82}
83
84func addOperationListNotebookInstanceLifecycleConfigsMiddlewares(stack *middleware.Stack, options Options) (err error) {
85	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListNotebookInstanceLifecycleConfigs{}, middleware.After)
86	if err != nil {
87		return err
88	}
89	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListNotebookInstanceLifecycleConfigs{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	if err = addSetLoggerMiddleware(stack, options); err != nil {
94		return err
95	}
96	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
97		return err
98	}
99	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
100		return err
101	}
102	if err = addResolveEndpointMiddleware(stack, options); err != nil {
103		return err
104	}
105	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
106		return err
107	}
108	if err = addRetryMiddlewares(stack, options); err != nil {
109		return err
110	}
111	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
118		return err
119	}
120	if err = addClientUserAgent(stack); err != nil {
121		return err
122	}
123	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
124		return err
125	}
126	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
127		return err
128	}
129	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListNotebookInstanceLifecycleConfigs(options.Region), middleware.Before); err != nil {
130		return err
131	}
132	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addResponseErrorMiddleware(stack); err != nil {
136		return err
137	}
138	if err = addRequestResponseLogging(stack, options); err != nil {
139		return err
140	}
141	return nil
142}
143
144// ListNotebookInstanceLifecycleConfigsAPIClient is a client that implements the
145// ListNotebookInstanceLifecycleConfigs operation.
146type ListNotebookInstanceLifecycleConfigsAPIClient interface {
147	ListNotebookInstanceLifecycleConfigs(context.Context, *ListNotebookInstanceLifecycleConfigsInput, ...func(*Options)) (*ListNotebookInstanceLifecycleConfigsOutput, error)
148}
149
150var _ ListNotebookInstanceLifecycleConfigsAPIClient = (*Client)(nil)
151
152// ListNotebookInstanceLifecycleConfigsPaginatorOptions is the paginator options
153// for ListNotebookInstanceLifecycleConfigs
154type ListNotebookInstanceLifecycleConfigsPaginatorOptions struct {
155	// The maximum number of lifecycle configurations to return in the response.
156	Limit int32
157
158	// Set to true if pagination should stop if the service returns a pagination token
159	// that matches the most recent token provided to the service.
160	StopOnDuplicateToken bool
161}
162
163// ListNotebookInstanceLifecycleConfigsPaginator is a paginator for
164// ListNotebookInstanceLifecycleConfigs
165type ListNotebookInstanceLifecycleConfigsPaginator struct {
166	options   ListNotebookInstanceLifecycleConfigsPaginatorOptions
167	client    ListNotebookInstanceLifecycleConfigsAPIClient
168	params    *ListNotebookInstanceLifecycleConfigsInput
169	nextToken *string
170	firstPage bool
171}
172
173// NewListNotebookInstanceLifecycleConfigsPaginator returns a new
174// ListNotebookInstanceLifecycleConfigsPaginator
175func NewListNotebookInstanceLifecycleConfigsPaginator(client ListNotebookInstanceLifecycleConfigsAPIClient, params *ListNotebookInstanceLifecycleConfigsInput, optFns ...func(*ListNotebookInstanceLifecycleConfigsPaginatorOptions)) *ListNotebookInstanceLifecycleConfigsPaginator {
176	options := ListNotebookInstanceLifecycleConfigsPaginatorOptions{}
177	if params.MaxResults != nil {
178		options.Limit = *params.MaxResults
179	}
180
181	for _, fn := range optFns {
182		fn(&options)
183	}
184
185	if params == nil {
186		params = &ListNotebookInstanceLifecycleConfigsInput{}
187	}
188
189	return &ListNotebookInstanceLifecycleConfigsPaginator{
190		options:   options,
191		client:    client,
192		params:    params,
193		firstPage: true,
194	}
195}
196
197// HasMorePages returns a boolean indicating whether more pages are available
198func (p *ListNotebookInstanceLifecycleConfigsPaginator) HasMorePages() bool {
199	return p.firstPage || p.nextToken != nil
200}
201
202// NextPage retrieves the next ListNotebookInstanceLifecycleConfigs page.
203func (p *ListNotebookInstanceLifecycleConfigsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListNotebookInstanceLifecycleConfigsOutput, error) {
204	if !p.HasMorePages() {
205		return nil, fmt.Errorf("no more pages available")
206	}
207
208	params := *p.params
209	params.NextToken = p.nextToken
210
211	var limit *int32
212	if p.options.Limit > 0 {
213		limit = &p.options.Limit
214	}
215	params.MaxResults = limit
216
217	result, err := p.client.ListNotebookInstanceLifecycleConfigs(ctx, &params, optFns...)
218	if err != nil {
219		return nil, err
220	}
221	p.firstPage = false
222
223	prevToken := p.nextToken
224	p.nextToken = result.NextToken
225
226	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
227		p.nextToken = nil
228	}
229
230	return result, nil
231}
232
233func newServiceMetadataMiddleware_opListNotebookInstanceLifecycleConfigs(region string) *awsmiddleware.RegisterServiceMetadata {
234	return &awsmiddleware.RegisterServiceMetadata{
235		Region:        region,
236		ServiceID:     ServiceID,
237		SigningName:   "sagemaker",
238		OperationName: "ListNotebookInstanceLifecycleConfigs",
239	}
240}
241