1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package robomaker
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/robomaker/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Lists world generator jobs.
16func (c *Client) ListWorldGenerationJobs(ctx context.Context, params *ListWorldGenerationJobsInput, optFns ...func(*Options)) (*ListWorldGenerationJobsOutput, error) {
17	if params == nil {
18		params = &ListWorldGenerationJobsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "ListWorldGenerationJobs", params, optFns, addOperationListWorldGenerationJobsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*ListWorldGenerationJobsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type ListWorldGenerationJobsInput struct {
32
33	// Optional filters to limit results. You can use status and templateId.
34	Filters []types.Filter
35
36	// When this parameter is used, ListWorldGeneratorJobs only returns maxResults
37	// results in a single page along with a nextToken response element. The remaining
38	// results of the initial request can be seen by sending another
39	// ListWorldGeneratorJobs request with the returned nextToken value. This value can
40	// be between 1 and 100. If this parameter is not used, then ListWorldGeneratorJobs
41	// returns up to 100 results and a nextToken value if applicable.
42	MaxResults *int32
43
44	// If the previous paginated request did not return all of the remaining results,
45	// the response object's nextToken parameter value is set to a token. To retrieve
46	// the next set of results, call ListWorldGenerationJobsRequest again and assign
47	// that token to the request object's nextToken parameter. If there are no
48	// remaining results, the previous response object's NextToken parameter is set to
49	// null.
50	NextToken *string
51}
52
53type ListWorldGenerationJobsOutput struct {
54
55	// Summary information for world generator jobs.
56	//
57	// This member is required.
58	WorldGenerationJobSummaries []types.WorldGenerationJobSummary
59
60	// If the previous paginated request did not return all of the remaining results,
61	// the response object's nextToken parameter value is set to a token. To retrieve
62	// the next set of results, call ListWorldGeneratorJobsRequest again and assign
63	// that token to the request object's nextToken parameter. If there are no
64	// remaining results, the previous response object's NextToken parameter is set to
65	// null.
66	NextToken *string
67
68	// Metadata pertaining to the operation's result.
69	ResultMetadata middleware.Metadata
70}
71
72func addOperationListWorldGenerationJobsMiddlewares(stack *middleware.Stack, options Options) (err error) {
73	err = stack.Serialize.Add(&awsRestjson1_serializeOpListWorldGenerationJobs{}, middleware.After)
74	if err != nil {
75		return err
76	}
77	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListWorldGenerationJobs{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	if err = addSetLoggerMiddleware(stack, options); err != nil {
82		return err
83	}
84	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
85		return err
86	}
87	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
88		return err
89	}
90	if err = addResolveEndpointMiddleware(stack, options); err != nil {
91		return err
92	}
93	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
94		return err
95	}
96	if err = addRetryMiddlewares(stack, options); err != nil {
97		return err
98	}
99	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
100		return err
101	}
102	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
106		return err
107	}
108	if err = addClientUserAgent(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListWorldGenerationJobs(options.Region), middleware.Before); err != nil {
118		return err
119	}
120	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addResponseErrorMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addRequestResponseLogging(stack, options); err != nil {
127		return err
128	}
129	return nil
130}
131
132// ListWorldGenerationJobsAPIClient is a client that implements the
133// ListWorldGenerationJobs operation.
134type ListWorldGenerationJobsAPIClient interface {
135	ListWorldGenerationJobs(context.Context, *ListWorldGenerationJobsInput, ...func(*Options)) (*ListWorldGenerationJobsOutput, error)
136}
137
138var _ ListWorldGenerationJobsAPIClient = (*Client)(nil)
139
140// ListWorldGenerationJobsPaginatorOptions is the paginator options for
141// ListWorldGenerationJobs
142type ListWorldGenerationJobsPaginatorOptions struct {
143	// When this parameter is used, ListWorldGeneratorJobs only returns maxResults
144	// results in a single page along with a nextToken response element. The remaining
145	// results of the initial request can be seen by sending another
146	// ListWorldGeneratorJobs request with the returned nextToken value. This value can
147	// be between 1 and 100. If this parameter is not used, then ListWorldGeneratorJobs
148	// returns up to 100 results and a nextToken value if applicable.
149	Limit int32
150
151	// Set to true if pagination should stop if the service returns a pagination token
152	// that matches the most recent token provided to the service.
153	StopOnDuplicateToken bool
154}
155
156// ListWorldGenerationJobsPaginator is a paginator for ListWorldGenerationJobs
157type ListWorldGenerationJobsPaginator struct {
158	options   ListWorldGenerationJobsPaginatorOptions
159	client    ListWorldGenerationJobsAPIClient
160	params    *ListWorldGenerationJobsInput
161	nextToken *string
162	firstPage bool
163}
164
165// NewListWorldGenerationJobsPaginator returns a new
166// ListWorldGenerationJobsPaginator
167func NewListWorldGenerationJobsPaginator(client ListWorldGenerationJobsAPIClient, params *ListWorldGenerationJobsInput, optFns ...func(*ListWorldGenerationJobsPaginatorOptions)) *ListWorldGenerationJobsPaginator {
168	if params == nil {
169		params = &ListWorldGenerationJobsInput{}
170	}
171
172	options := ListWorldGenerationJobsPaginatorOptions{}
173	if params.MaxResults != nil {
174		options.Limit = *params.MaxResults
175	}
176
177	for _, fn := range optFns {
178		fn(&options)
179	}
180
181	return &ListWorldGenerationJobsPaginator{
182		options:   options,
183		client:    client,
184		params:    params,
185		firstPage: true,
186	}
187}
188
189// HasMorePages returns a boolean indicating whether more pages are available
190func (p *ListWorldGenerationJobsPaginator) HasMorePages() bool {
191	return p.firstPage || p.nextToken != nil
192}
193
194// NextPage retrieves the next ListWorldGenerationJobs page.
195func (p *ListWorldGenerationJobsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListWorldGenerationJobsOutput, error) {
196	if !p.HasMorePages() {
197		return nil, fmt.Errorf("no more pages available")
198	}
199
200	params := *p.params
201	params.NextToken = p.nextToken
202
203	var limit *int32
204	if p.options.Limit > 0 {
205		limit = &p.options.Limit
206	}
207	params.MaxResults = limit
208
209	result, err := p.client.ListWorldGenerationJobs(ctx, &params, optFns...)
210	if err != nil {
211		return nil, err
212	}
213	p.firstPage = false
214
215	prevToken := p.nextToken
216	p.nextToken = result.NextToken
217
218	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
219		p.nextToken = nil
220	}
221
222	return result, nil
223}
224
225func newServiceMetadataMiddleware_opListWorldGenerationJobs(region string) *awsmiddleware.RegisterServiceMetadata {
226	return &awsmiddleware.RegisterServiceMetadata{
227		Region:        region,
228		ServiceID:     ServiceID,
229		SigningName:   "robomaker",
230		OperationName: "ListWorldGenerationJobs",
231	}
232}
233