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