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	"time"
14)
15
16// Starts a new simulation job batch. The batch is defined using one or more
17// SimulationJobRequest objects.
18func (c *Client) StartSimulationJobBatch(ctx context.Context, params *StartSimulationJobBatchInput, optFns ...func(*Options)) (*StartSimulationJobBatchOutput, error) {
19	if params == nil {
20		params = &StartSimulationJobBatchInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "StartSimulationJobBatch", params, optFns, addOperationStartSimulationJobBatchMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*StartSimulationJobBatchOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33type StartSimulationJobBatchInput struct {
34
35	// A list of simulation job requests to create in the batch.
36	//
37	// This member is required.
38	CreateSimulationJobRequests []types.SimulationJobRequest
39
40	// The batch policy.
41	BatchPolicy *types.BatchPolicy
42
43	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
44	// the request.
45	ClientRequestToken *string
46
47	// A map that contains tag keys and tag values that are attached to the deployment
48	// job batch.
49	Tags map[string]string
50}
51
52type StartSimulationJobBatchOutput struct {
53
54	// The Amazon Resource Name (arn) of the batch.
55	Arn *string
56
57	// The batch policy.
58	BatchPolicy *types.BatchPolicy
59
60	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
61	// the request.
62	ClientRequestToken *string
63
64	// The time, in milliseconds since the epoch, when the simulation job batch was
65	// created.
66	CreatedAt *time.Time
67
68	// A list of created simulation job request summaries.
69	CreatedRequests []types.SimulationJobSummary
70
71	// A list of failed simulation job requests. The request failed to be created into
72	// a simulation job. Failed requests do not have a simulation job ID.
73	FailedRequests []types.FailedCreateSimulationJobRequest
74
75	// The failure code if the simulation job batch failed.
76	FailureCode types.SimulationJobBatchErrorCode
77
78	// The reason the simulation job batch failed.
79	FailureReason *string
80
81	// A list of pending simulation job requests. These requests have not yet been
82	// created into simulation jobs.
83	PendingRequests []types.SimulationJobRequest
84
85	// The status of the simulation job batch. Pending The simulation job batch request
86	// is pending. InProgress The simulation job batch is in progress. Failed The
87	// simulation job batch failed. One or more simulation job requests could not be
88	// completed due to an internal failure (like InternalServiceError). See
89	// failureCode and failureReason for more information. Completed The simulation
90	// batch job completed. A batch is complete when (1) there are no pending
91	// simulation job requests in the batch and none of the failed simulation job
92	// requests are due to InternalServiceError and (2) when all created simulation
93	// jobs have reached a terminal state (for example, Completed or Failed). Canceled
94	// The simulation batch job was cancelled. Canceling The simulation batch job is
95	// being cancelled. Completing The simulation batch job is completing. TimingOut
96	// The simulation job batch is timing out. If a batch timing out, and there are
97	// pending requests that were failing due to an internal failure (like
98	// InternalServiceError), the batch status will be Failed. If there are no such
99	// failing request, the batch status will be TimedOut. TimedOut The simulation
100	// batch job timed out.
101	Status types.SimulationJobBatchStatus
102
103	// A map that contains tag keys and tag values that are attached to the deployment
104	// job batch.
105	Tags map[string]string
106
107	// Metadata pertaining to the operation's result.
108	ResultMetadata middleware.Metadata
109}
110
111func addOperationStartSimulationJobBatchMiddlewares(stack *middleware.Stack, options Options) (err error) {
112	err = stack.Serialize.Add(&awsRestjson1_serializeOpStartSimulationJobBatch{}, middleware.After)
113	if err != nil {
114		return err
115	}
116	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpStartSimulationJobBatch{}, middleware.After)
117	if err != nil {
118		return err
119	}
120	if err = addSetLoggerMiddleware(stack, options); err != nil {
121		return err
122	}
123	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
124		return err
125	}
126	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addResolveEndpointMiddleware(stack, options); err != nil {
130		return err
131	}
132	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
133		return err
134	}
135	if err = addRetryMiddlewares(stack, options); err != nil {
136		return err
137	}
138	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
139		return err
140	}
141	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
142		return err
143	}
144	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
145		return err
146	}
147	if err = addClientUserAgent(stack); err != nil {
148		return err
149	}
150	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
151		return err
152	}
153	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
154		return err
155	}
156	if err = addIdempotencyToken_opStartSimulationJobBatchMiddleware(stack, options); err != nil {
157		return err
158	}
159	if err = addOpStartSimulationJobBatchValidationMiddleware(stack); err != nil {
160		return err
161	}
162	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartSimulationJobBatch(options.Region), middleware.Before); err != nil {
163		return err
164	}
165	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
166		return err
167	}
168	if err = addResponseErrorMiddleware(stack); err != nil {
169		return err
170	}
171	if err = addRequestResponseLogging(stack, options); err != nil {
172		return err
173	}
174	return nil
175}
176
177type idempotencyToken_initializeOpStartSimulationJobBatch struct {
178	tokenProvider IdempotencyTokenProvider
179}
180
181func (*idempotencyToken_initializeOpStartSimulationJobBatch) ID() string {
182	return "OperationIdempotencyTokenAutoFill"
183}
184
185func (m *idempotencyToken_initializeOpStartSimulationJobBatch) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
186	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
187) {
188	if m.tokenProvider == nil {
189		return next.HandleInitialize(ctx, in)
190	}
191
192	input, ok := in.Parameters.(*StartSimulationJobBatchInput)
193	if !ok {
194		return out, metadata, fmt.Errorf("expected middleware input to be of type *StartSimulationJobBatchInput ")
195	}
196
197	if input.ClientRequestToken == nil {
198		t, err := m.tokenProvider.GetIdempotencyToken()
199		if err != nil {
200			return out, metadata, err
201		}
202		input.ClientRequestToken = &t
203	}
204	return next.HandleInitialize(ctx, in)
205}
206func addIdempotencyToken_opStartSimulationJobBatchMiddleware(stack *middleware.Stack, cfg Options) error {
207	return stack.Initialize.Add(&idempotencyToken_initializeOpStartSimulationJobBatch{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
208}
209
210func newServiceMetadataMiddleware_opStartSimulationJobBatch(region string) *awsmiddleware.RegisterServiceMetadata {
211	return &awsmiddleware.RegisterServiceMetadata{
212		Region:        region,
213		ServiceID:     ServiceID,
214		SigningName:   "robomaker",
215		OperationName: "StartSimulationJobBatch",
216	}
217}
218