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// Creates an Batch job queue. When you create a job queue, you associate one or
15// more compute environments to the queue and assign an order of preference for the
16// compute environments. You also set a priority to the job queue that determines
17// the order that the Batch scheduler places jobs onto its associated compute
18// environments. For example, if a compute environment is associated with more than
19// one job queue, the job queue with a higher priority is given preference for
20// scheduling jobs to that compute environment.
21func (c *Client) CreateJobQueue(ctx context.Context, params *CreateJobQueueInput, optFns ...func(*Options)) (*CreateJobQueueOutput, error) {
22	if params == nil {
23		params = &CreateJobQueueInput{}
24	}
25
26	result, metadata, err := c.invokeOperation(ctx, "CreateJobQueue", params, optFns, c.addOperationCreateJobQueueMiddlewares)
27	if err != nil {
28		return nil, err
29	}
30
31	out := result.(*CreateJobQueueOutput)
32	out.ResultMetadata = metadata
33	return out, nil
34}
35
36// Contains the parameters for CreateJobQueue.
37type CreateJobQueueInput struct {
38
39	// The set of compute environments mapped to a job queue and their order relative
40	// to each other. The job scheduler uses this parameter to determine which compute
41	// environment should run a specific job. Compute environments must be in the VALID
42	// state before you can associate them with a job queue. You can associate up to
43	// three compute environments with a job queue. All of the compute environments
44	// must be either EC2 (EC2 or SPOT) or Fargate (FARGATE or FARGATE_SPOT); EC2 and
45	// Fargate compute environments can't be mixed. All compute environments that are
46	// associated with a job queue must share the same architecture. Batch doesn't
47	// support mixing compute environment architecture types in a single job queue.
48	//
49	// This member is required.
50	ComputeEnvironmentOrder []types.ComputeEnvironmentOrder
51
52	// The name of the job queue. Up to 128 letters (uppercase and lowercase), numbers,
53	// and underscores are allowed.
54	//
55	// This member is required.
56	JobQueueName *string
57
58	// The priority of the job queue. Job queues with a higher priority (or a higher
59	// integer value for the priority parameter) are evaluated first when associated
60	// with the same compute environment. Priority is determined in descending order.
61	// For example, a job queue with a priority value of 10 is given scheduling
62	// preference over a job queue with a priority value of 1. All of the compute
63	// environments must be either EC2 (EC2 or SPOT) or Fargate (FARGATE or
64	// FARGATE_SPOT); EC2 and Fargate compute environments can't be mixed.
65	//
66	// This member is required.
67	Priority int32
68
69	// The state of the job queue. If the job queue state is ENABLED, it is able to
70	// accept jobs. If the job queue state is DISABLED, new jobs can't be added to the
71	// queue, but jobs already in the queue can finish.
72	State types.JQState
73
74	// The tags that you apply to the job queue to help you categorize and organize
75	// your resources. Each tag consists of a key and an optional value. For more
76	// information, see Tagging your Batch resources
77	// (https://docs.aws.amazon.com/batch/latest/userguide/using-tags.html) in Batch
78	// User Guide.
79	Tags map[string]string
80
81	noSmithyDocumentSerde
82}
83
84type CreateJobQueueOutput struct {
85
86	// The Amazon Resource Name (ARN) of the job queue.
87	//
88	// This member is required.
89	JobQueueArn *string
90
91	// The name of the job queue.
92	//
93	// This member is required.
94	JobQueueName *string
95
96	// Metadata pertaining to the operation's result.
97	ResultMetadata middleware.Metadata
98
99	noSmithyDocumentSerde
100}
101
102func (c *Client) addOperationCreateJobQueueMiddlewares(stack *middleware.Stack, options Options) (err error) {
103	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateJobQueue{}, middleware.After)
104	if err != nil {
105		return err
106	}
107	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateJobQueue{}, middleware.After)
108	if err != nil {
109		return err
110	}
111	if err = addSetLoggerMiddleware(stack, options); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
118		return err
119	}
120	if err = addResolveEndpointMiddleware(stack, options); err != nil {
121		return err
122	}
123	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
124		return err
125	}
126	if err = addRetryMiddlewares(stack, options); err != nil {
127		return err
128	}
129	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
130		return err
131	}
132	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
133		return err
134	}
135	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
136		return err
137	}
138	if err = addClientUserAgent(stack); err != nil {
139		return err
140	}
141	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
145		return err
146	}
147	if err = addOpCreateJobQueueValidationMiddleware(stack); err != nil {
148		return err
149	}
150	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateJobQueue(options.Region), middleware.Before); err != nil {
151		return err
152	}
153	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
154		return err
155	}
156	if err = addResponseErrorMiddleware(stack); err != nil {
157		return err
158	}
159	if err = addRequestResponseLogging(stack, options); err != nil {
160		return err
161	}
162	return nil
163}
164
165func newServiceMetadataMiddleware_opCreateJobQueue(region string) *awsmiddleware.RegisterServiceMetadata {
166	return &awsmiddleware.RegisterServiceMetadata{
167		Region:        region,
168		ServiceID:     ServiceID,
169		SigningName:   "batch",
170		OperationName: "CreateJobQueue",
171	}
172}
173