1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package emr
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/emr/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13	"time"
14)
15
16// Provides summaries of all notebook executions. You can filter the list based on
17// multiple criteria such as status, time range, and editor id. Returns a maximum
18// of 50 notebook executions and a marker to track the paging of a longer notebook
19// execution list across multiple ListNotebookExecution calls.
20func (c *Client) ListNotebookExecutions(ctx context.Context, params *ListNotebookExecutionsInput, optFns ...func(*Options)) (*ListNotebookExecutionsOutput, error) {
21	if params == nil {
22		params = &ListNotebookExecutionsInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "ListNotebookExecutions", params, optFns, addOperationListNotebookExecutionsMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*ListNotebookExecutionsOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35type ListNotebookExecutionsInput struct {
36
37	// The unique ID of the editor associated with the notebook execution.
38	EditorId *string
39
40	// The beginning of time range filter for listing notebook executions. The default
41	// is the timestamp of 30 days ago.
42	From *time.Time
43
44	// The pagination token, returned by a previous ListNotebookExecutions call, that
45	// indicates the start of the list for this ListNotebookExecutions call.
46	Marker *string
47
48	// The status filter for listing notebook executions.
49	//
50	// * START_PENDING indicates
51	// that the cluster has received the execution request but execution has not
52	// begun.
53	//
54	// * STARTING indicates that the execution is starting on the cluster.
55	//
56	// *
57	// RUNNING indicates that the execution is being processed by the cluster.
58	//
59	// *
60	// FINISHING indicates that execution processing is in the final stages.
61	//
62	// *
63	// FINISHED indicates that the execution has completed without error.
64	//
65	// * FAILING
66	// indicates that the execution is failing and will not finish successfully.
67	//
68	// *
69	// FAILED indicates that the execution failed.
70	//
71	// * STOP_PENDING indicates that the
72	// cluster has received a StopNotebookExecution request and the stop is pending.
73	//
74	// *
75	// STOPPING indicates that the cluster is in the process of stopping the execution
76	// as a result of a StopNotebookExecution request.
77	//
78	// * STOPPED indicates that the
79	// execution stopped because of a StopNotebookExecution request.
80	Status types.NotebookExecutionStatus
81
82	// The end of time range filter for listing notebook executions. The default is the
83	// current timestamp.
84	To *time.Time
85}
86
87type ListNotebookExecutionsOutput struct {
88
89	// A pagination token that a subsequent ListNotebookExecutions can use to determine
90	// the next set of results to retrieve.
91	Marker *string
92
93	// A list of notebook executions.
94	NotebookExecutions []types.NotebookExecutionSummary
95
96	// Metadata pertaining to the operation's result.
97	ResultMetadata middleware.Metadata
98}
99
100func addOperationListNotebookExecutionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
101	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListNotebookExecutions{}, middleware.After)
102	if err != nil {
103		return err
104	}
105	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListNotebookExecutions{}, middleware.After)
106	if err != nil {
107		return err
108	}
109	if err = addSetLoggerMiddleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addResolveEndpointMiddleware(stack, options); err != nil {
119		return err
120	}
121	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
122		return err
123	}
124	if err = addRetryMiddlewares(stack, options); err != nil {
125		return err
126	}
127	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
128		return err
129	}
130	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
131		return err
132	}
133	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
134		return err
135	}
136	if err = addClientUserAgent(stack); err != nil {
137		return err
138	}
139	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
140		return err
141	}
142	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
143		return err
144	}
145	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListNotebookExecutions(options.Region), middleware.Before); err != nil {
146		return err
147	}
148	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
149		return err
150	}
151	if err = addResponseErrorMiddleware(stack); err != nil {
152		return err
153	}
154	if err = addRequestResponseLogging(stack, options); err != nil {
155		return err
156	}
157	return nil
158}
159
160// ListNotebookExecutionsAPIClient is a client that implements the
161// ListNotebookExecutions operation.
162type ListNotebookExecutionsAPIClient interface {
163	ListNotebookExecutions(context.Context, *ListNotebookExecutionsInput, ...func(*Options)) (*ListNotebookExecutionsOutput, error)
164}
165
166var _ ListNotebookExecutionsAPIClient = (*Client)(nil)
167
168// ListNotebookExecutionsPaginatorOptions is the paginator options for
169// ListNotebookExecutions
170type ListNotebookExecutionsPaginatorOptions struct {
171	// Set to true if pagination should stop if the service returns a pagination token
172	// that matches the most recent token provided to the service.
173	StopOnDuplicateToken bool
174}
175
176// ListNotebookExecutionsPaginator is a paginator for ListNotebookExecutions
177type ListNotebookExecutionsPaginator struct {
178	options   ListNotebookExecutionsPaginatorOptions
179	client    ListNotebookExecutionsAPIClient
180	params    *ListNotebookExecutionsInput
181	nextToken *string
182	firstPage bool
183}
184
185// NewListNotebookExecutionsPaginator returns a new ListNotebookExecutionsPaginator
186func NewListNotebookExecutionsPaginator(client ListNotebookExecutionsAPIClient, params *ListNotebookExecutionsInput, optFns ...func(*ListNotebookExecutionsPaginatorOptions)) *ListNotebookExecutionsPaginator {
187	options := ListNotebookExecutionsPaginatorOptions{}
188
189	for _, fn := range optFns {
190		fn(&options)
191	}
192
193	if params == nil {
194		params = &ListNotebookExecutionsInput{}
195	}
196
197	return &ListNotebookExecutionsPaginator{
198		options:   options,
199		client:    client,
200		params:    params,
201		firstPage: true,
202	}
203}
204
205// HasMorePages returns a boolean indicating whether more pages are available
206func (p *ListNotebookExecutionsPaginator) HasMorePages() bool {
207	return p.firstPage || p.nextToken != nil
208}
209
210// NextPage retrieves the next ListNotebookExecutions page.
211func (p *ListNotebookExecutionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListNotebookExecutionsOutput, error) {
212	if !p.HasMorePages() {
213		return nil, fmt.Errorf("no more pages available")
214	}
215
216	params := *p.params
217	params.Marker = p.nextToken
218
219	result, err := p.client.ListNotebookExecutions(ctx, &params, optFns...)
220	if err != nil {
221		return nil, err
222	}
223	p.firstPage = false
224
225	prevToken := p.nextToken
226	p.nextToken = result.Marker
227
228	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
229		p.nextToken = nil
230	}
231
232	return result, nil
233}
234
235func newServiceMetadataMiddleware_opListNotebookExecutions(region string) *awsmiddleware.RegisterServiceMetadata {
236	return &awsmiddleware.RegisterServiceMetadata{
237		Region:        region,
238		ServiceID:     ServiceID,
239		SigningName:   "elasticmapreduce",
240		OperationName: "ListNotebookExecutions",
241	}
242}
243