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// Creates a simulation job. After 90 days, simulation jobs expire and will be
17// deleted. They will no longer be accessible.
18func (c *Client) CreateSimulationJob(ctx context.Context, params *CreateSimulationJobInput, optFns ...func(*Options)) (*CreateSimulationJobOutput, error) {
19	if params == nil {
20		params = &CreateSimulationJobInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "CreateSimulationJob", params, optFns, addOperationCreateSimulationJobMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*CreateSimulationJobOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33type CreateSimulationJobInput struct {
34
35	// The IAM role name that allows the simulation instance to call the AWS APIs that
36	// are specified in its associated policies on your behalf. This is how credentials
37	// are passed in to your simulation job.
38	//
39	// This member is required.
40	IamRole *string
41
42	// The maximum simulation job duration in seconds (up to 14 days or 1,209,600
43	// seconds. When maxJobDurationInSeconds is reached, the simulation job will status
44	// will transition to Completed.
45	//
46	// This member is required.
47	MaxJobDurationInSeconds int64
48
49	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
50	// the request.
51	ClientRequestToken *string
52
53	// Compute information for the simulation job.
54	Compute *types.Compute
55
56	// Specify data sources to mount read-only files from S3 into your simulation.
57	// These files are available under /opt/robomaker/datasources/data_source_name.
58	// There is a limit of 100 files and a combined size of 25GB for all
59	// DataSourceConfig objects.
60	DataSources []types.DataSourceConfig
61
62	// The failure behavior the simulation job. Continue Restart the simulation job in
63	// the same host instance. Fail Stop the simulation job and terminate the instance.
64	FailureBehavior types.FailureBehavior
65
66	// The logging configuration.
67	LoggingConfig *types.LoggingConfig
68
69	// Location for output files generated by the simulation job.
70	OutputLocation *types.OutputLocation
71
72	// The robot application to use in the simulation job.
73	RobotApplications []types.RobotApplicationConfig
74
75	// The simulation application to use in the simulation job.
76	SimulationApplications []types.SimulationApplicationConfig
77
78	// A map that contains tag keys and tag values that are attached to the simulation
79	// job.
80	Tags map[string]string
81
82	// If your simulation job accesses resources in a VPC, you provide this parameter
83	// identifying the list of security group IDs and subnet IDs. These must belong to
84	// the same VPC. You must provide at least one security group and one subnet ID.
85	VpcConfig *types.VPCConfig
86}
87
88type CreateSimulationJobOutput struct {
89
90	// The Amazon Resource Name (ARN) of the simulation job.
91	Arn *string
92
93	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
94	// the request.
95	ClientRequestToken *string
96
97	// Compute information for the simulation job.
98	Compute *types.ComputeResponse
99
100	// The data sources for the simulation job.
101	DataSources []types.DataSource
102
103	// the failure behavior for the simulation job.
104	FailureBehavior types.FailureBehavior
105
106	// The failure code of the simulation job if it failed: InternalServiceError
107	// Internal service error. RobotApplicationCrash Robot application exited
108	// abnormally. SimulationApplicationCrash Simulation application exited abnormally.
109	// BadPermissionsRobotApplication Robot application bundle could not be downloaded.
110	// BadPermissionsSimulationApplication Simulation application bundle could not be
111	// downloaded. BadPermissionsS3Output Unable to publish outputs to
112	// customer-provided S3 bucket. BadPermissionsCloudwatchLogs Unable to publish logs
113	// to customer-provided CloudWatch Logs resource. SubnetIpLimitExceeded Subnet IP
114	// limit exceeded. ENILimitExceeded ENI limit exceeded.
115	// BadPermissionsUserCredentials Unable to use the Role provided.
116	// InvalidBundleRobotApplication Robot bundle cannot be extracted (invalid format,
117	// bundling error, or other issue). InvalidBundleSimulationApplication Simulation
118	// bundle cannot be extracted (invalid format, bundling error, or other issue).
119	// RobotApplicationVersionMismatchedEtag Etag for RobotApplication does not match
120	// value during version creation. SimulationApplicationVersionMismatchedEtag Etag
121	// for SimulationApplication does not match value during version creation.
122	FailureCode types.SimulationJobErrorCode
123
124	// The IAM role that allows the simulation job to call the AWS APIs that are
125	// specified in its associated policies on your behalf.
126	IamRole *string
127
128	// The time, in milliseconds since the epoch, when the simulation job was last
129	// started.
130	LastStartedAt *time.Time
131
132	// The time, in milliseconds since the epoch, when the simulation job was last
133	// updated.
134	LastUpdatedAt *time.Time
135
136	// The logging configuration.
137	LoggingConfig *types.LoggingConfig
138
139	// The maximum simulation job duration in seconds.
140	MaxJobDurationInSeconds int64
141
142	// Simulation job output files location.
143	OutputLocation *types.OutputLocation
144
145	// The robot application used by the simulation job.
146	RobotApplications []types.RobotApplicationConfig
147
148	// The simulation application used by the simulation job.
149	SimulationApplications []types.SimulationApplicationConfig
150
151	// The simulation job execution duration in milliseconds.
152	SimulationTimeMillis int64
153
154	// The status of the simulation job.
155	Status types.SimulationJobStatus
156
157	// The list of all tags added to the simulation job.
158	Tags map[string]string
159
160	// Information about the vpc configuration.
161	VpcConfig *types.VPCConfigResponse
162
163	// Metadata pertaining to the operation's result.
164	ResultMetadata middleware.Metadata
165}
166
167func addOperationCreateSimulationJobMiddlewares(stack *middleware.Stack, options Options) (err error) {
168	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateSimulationJob{}, middleware.After)
169	if err != nil {
170		return err
171	}
172	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateSimulationJob{}, middleware.After)
173	if err != nil {
174		return err
175	}
176	if err = addSetLoggerMiddleware(stack, options); err != nil {
177		return err
178	}
179	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
180		return err
181	}
182	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
183		return err
184	}
185	if err = addResolveEndpointMiddleware(stack, options); err != nil {
186		return err
187	}
188	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
189		return err
190	}
191	if err = addRetryMiddlewares(stack, options); err != nil {
192		return err
193	}
194	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
195		return err
196	}
197	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
198		return err
199	}
200	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
201		return err
202	}
203	if err = addClientUserAgent(stack); err != nil {
204		return err
205	}
206	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
207		return err
208	}
209	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
210		return err
211	}
212	if err = addIdempotencyToken_opCreateSimulationJobMiddleware(stack, options); err != nil {
213		return err
214	}
215	if err = addOpCreateSimulationJobValidationMiddleware(stack); err != nil {
216		return err
217	}
218	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateSimulationJob(options.Region), middleware.Before); err != nil {
219		return err
220	}
221	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
222		return err
223	}
224	if err = addResponseErrorMiddleware(stack); err != nil {
225		return err
226	}
227	if err = addRequestResponseLogging(stack, options); err != nil {
228		return err
229	}
230	return nil
231}
232
233type idempotencyToken_initializeOpCreateSimulationJob struct {
234	tokenProvider IdempotencyTokenProvider
235}
236
237func (*idempotencyToken_initializeOpCreateSimulationJob) ID() string {
238	return "OperationIdempotencyTokenAutoFill"
239}
240
241func (m *idempotencyToken_initializeOpCreateSimulationJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
242	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
243) {
244	if m.tokenProvider == nil {
245		return next.HandleInitialize(ctx, in)
246	}
247
248	input, ok := in.Parameters.(*CreateSimulationJobInput)
249	if !ok {
250		return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateSimulationJobInput ")
251	}
252
253	if input.ClientRequestToken == nil {
254		t, err := m.tokenProvider.GetIdempotencyToken()
255		if err != nil {
256			return out, metadata, err
257		}
258		input.ClientRequestToken = &t
259	}
260	return next.HandleInitialize(ctx, in)
261}
262func addIdempotencyToken_opCreateSimulationJobMiddleware(stack *middleware.Stack, cfg Options) error {
263	return stack.Initialize.Add(&idempotencyToken_initializeOpCreateSimulationJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
264}
265
266func newServiceMetadataMiddleware_opCreateSimulationJob(region string) *awsmiddleware.RegisterServiceMetadata {
267	return &awsmiddleware.RegisterServiceMetadata{
268		Region:        region,
269		ServiceID:     ServiceID,
270		SigningName:   "robomaker",
271		OperationName: "CreateSimulationJob",
272	}
273}
274