1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package batch
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/batch/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Registers an AWS Batch job definition.
15func (c *Client) RegisterJobDefinition(ctx context.Context, params *RegisterJobDefinitionInput, optFns ...func(*Options)) (*RegisterJobDefinitionOutput, error) {
16	if params == nil {
17		params = &RegisterJobDefinitionInput{}
18	}
19
20	result, metadata, err := c.invokeOperation(ctx, "RegisterJobDefinition", params, optFns, addOperationRegisterJobDefinitionMiddlewares)
21	if err != nil {
22		return nil, err
23	}
24
25	out := result.(*RegisterJobDefinitionOutput)
26	out.ResultMetadata = metadata
27	return out, nil
28}
29
30// Contains the parameters for RegisterJobDefinition.
31type RegisterJobDefinitionInput struct {
32
33	// The name of the job definition to register. Up to 128 letters (uppercase and
34	// lowercase), numbers, hyphens, and underscores are allowed.
35	//
36	// This member is required.
37	JobDefinitionName *string
38
39	// The type of job definition. For more information about multi-node parallel jobs,
40	// see Creating a multi-node parallel job definition
41	// (https://docs.aws.amazon.com/batch/latest/userguide/multi-node-job-def.html) in
42	// the AWS Batch User Guide. If the job is run on Fargate resources, then multinode
43	// isn't supported.
44	//
45	// This member is required.
46	Type types.JobDefinitionType
47
48	// An object with various properties specific to single-node container-based jobs.
49	// If the job definition's type parameter is container, then you must specify
50	// either containerProperties or nodeProperties. If the job runs on Fargate
51	// resources, then you must not specify nodeProperties; use only
52	// containerProperties.
53	ContainerProperties *types.ContainerProperties
54
55	// An object with various properties specific to multi-node parallel jobs. If you
56	// specify node properties for a job, it becomes a multi-node parallel job. For
57	// more information, see Multi-node Parallel Jobs
58	// (https://docs.aws.amazon.com/batch/latest/userguide/multi-node-parallel-jobs.html)
59	// in the AWS Batch User Guide. If the job definition's type parameter is
60	// container, then you must specify either containerProperties or nodeProperties.
61	// If the job runs on Fargate resources, then you must not specify nodeProperties;
62	// use containerProperties instead.
63	NodeProperties *types.NodeProperties
64
65	// Default parameter substitution placeholders to set in the job definition.
66	// Parameters are specified as a key-value pair mapping. Parameters in a SubmitJob
67	// request override any corresponding parameter defaults from the job definition.
68	Parameters map[string]string
69
70	// The platform capabilities required by the job definition. If no value is
71	// specified, it defaults to EC2. To run the job on Fargate resources, specify
72	// FARGATE.
73	PlatformCapabilities []types.PlatformCapability
74
75	// Specifies whether to propagate the tags from the job or job definition to the
76	// corresponding Amazon ECS task. If no value is specified, the tags are not
77	// propagated. Tags can only be propagated to the tasks during task creation. For
78	// tags with the same name, job tags are given priority over job definitions tags.
79	// If the total number of combined tags from the job and job definition is over 50,
80	// the job is moved to the FAILED state.
81	PropagateTags bool
82
83	// The retry strategy to use for failed jobs that are submitted with this job
84	// definition. Any retry strategy that's specified during a SubmitJob operation
85	// overrides the retry strategy defined here. If a job is terminated due to a
86	// timeout, it isn't retried.
87	RetryStrategy *types.RetryStrategy
88
89	// The tags that you apply to the job definition to help you categorize and
90	// organize your resources. Each tag consists of a key and an optional value. For
91	// more information, see Tagging AWS Resources
92	// (https://docs.aws.amazon.com/batch/latest/userguide/using-tags.html) in AWS
93	// Batch User Guide.
94	Tags map[string]string
95
96	// The timeout configuration for jobs that are submitted with this job definition,
97	// after which AWS Batch terminates your jobs if they have not finished. If a job
98	// is terminated due to a timeout, it isn't retried. The minimum value for the
99	// timeout is 60 seconds. Any timeout configuration that's specified during a
100	// SubmitJob operation overrides the timeout configuration defined here. For more
101	// information, see Job Timeouts
102	// (https://docs.aws.amazon.com/batch/latest/userguide/job_timeouts.html) in the
103	// AWS Batch User Guide.
104	Timeout *types.JobTimeout
105}
106
107type RegisterJobDefinitionOutput struct {
108
109	// The Amazon Resource Name (ARN) of the job definition.
110	//
111	// This member is required.
112	JobDefinitionArn *string
113
114	// The name of the job definition.
115	//
116	// This member is required.
117	JobDefinitionName *string
118
119	// The revision of the job definition.
120	//
121	// This member is required.
122	Revision int32
123
124	// Metadata pertaining to the operation's result.
125	ResultMetadata middleware.Metadata
126}
127
128func addOperationRegisterJobDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
129	err = stack.Serialize.Add(&awsRestjson1_serializeOpRegisterJobDefinition{}, middleware.After)
130	if err != nil {
131		return err
132	}
133	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpRegisterJobDefinition{}, middleware.After)
134	if err != nil {
135		return err
136	}
137	if err = addSetLoggerMiddleware(stack, options); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
141		return err
142	}
143	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addResolveEndpointMiddleware(stack, options); err != nil {
147		return err
148	}
149	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
150		return err
151	}
152	if err = addRetryMiddlewares(stack, options); err != nil {
153		return err
154	}
155	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
156		return err
157	}
158	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
159		return err
160	}
161	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
162		return err
163	}
164	if err = addClientUserAgent(stack); err != nil {
165		return err
166	}
167	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
168		return err
169	}
170	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
171		return err
172	}
173	if err = addOpRegisterJobDefinitionValidationMiddleware(stack); err != nil {
174		return err
175	}
176	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opRegisterJobDefinition(options.Region), middleware.Before); err != nil {
177		return err
178	}
179	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
180		return err
181	}
182	if err = addResponseErrorMiddleware(stack); err != nil {
183		return err
184	}
185	if err = addRequestResponseLogging(stack, options); err != nil {
186		return err
187	}
188	return nil
189}
190
191func newServiceMetadataMiddleware_opRegisterJobDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
192	return &awsmiddleware.RegisterServiceMetadata{
193		Region:        region,
194		ServiceID:     ServiceID,
195		SigningName:   "batch",
196		OperationName: "RegisterJobDefinition",
197	}
198}
199