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