Class: Aws::Batch::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::Batch::Client
- Includes:
- ClientStubs
- Defined in:
- gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb
Overview
An API client for Batch. To construct a client, you need to configure a :region
and :credentials
.
client = Aws::Batch::Client.new(
region: region_name,
credentials: credentials,
# ...
)
For details on configuring region and credentials see the developer guide.
See #initialize for a full list of supported configuration options.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
API Operations collapse
-
#cancel_job(params = {}) ⇒ Struct
Cancels a job in an Batch job queue.
-
#create_compute_environment(params = {}) ⇒ Types::CreateComputeEnvironmentResponse
Creates an Batch compute environment.
-
#create_job_queue(params = {}) ⇒ Types::CreateJobQueueResponse
Creates an Batch job queue.
-
#create_scheduling_policy(params = {}) ⇒ Types::CreateSchedulingPolicyResponse
Creates an Batch scheduling policy.
-
#delete_compute_environment(params = {}) ⇒ Struct
Deletes an Batch compute environment.
-
#delete_job_queue(params = {}) ⇒ Struct
Deletes the specified job queue.
-
#delete_scheduling_policy(params = {}) ⇒ Struct
Deletes the specified scheduling policy.
-
#deregister_job_definition(params = {}) ⇒ Struct
Deregisters an Batch job definition.
-
#describe_compute_environments(params = {}) ⇒ Types::DescribeComputeEnvironmentsResponse
Describes one or more of your compute environments.
-
#describe_job_definitions(params = {}) ⇒ Types::DescribeJobDefinitionsResponse
Describes a list of job definitions.
-
#describe_job_queues(params = {}) ⇒ Types::DescribeJobQueuesResponse
Describes one or more of your job queues.
-
#describe_jobs(params = {}) ⇒ Types::DescribeJobsResponse
Describes a list of Batch jobs.
-
#describe_scheduling_policies(params = {}) ⇒ Types::DescribeSchedulingPoliciesResponse
Describes one or more of your scheduling policies.
-
#list_jobs(params = {}) ⇒ Types::ListJobsResponse
Returns a list of Batch jobs.
-
#list_scheduling_policies(params = {}) ⇒ Types::ListSchedulingPoliciesResponse
Returns a list of Batch scheduling policies.
-
#list_tags_for_resource(params = {}) ⇒ Types::ListTagsForResourceResponse
Lists the tags for an Batch resource.
-
#register_job_definition(params = {}) ⇒ Types::RegisterJobDefinitionResponse
Registers an Batch job definition.
-
#submit_job(params = {}) ⇒ Types::SubmitJobResponse
Submits an Batch job from a job definition.
-
#tag_resource(params = {}) ⇒ Struct
Associates the specified tags to a resource with the specified
resourceArn
. -
#terminate_job(params = {}) ⇒ Struct
Terminates a job in a job queue.
-
#untag_resource(params = {}) ⇒ Struct
Deletes specified tags from an Batch resource.
-
#update_compute_environment(params = {}) ⇒ Types::UpdateComputeEnvironmentResponse
Updates an Batch compute environment.
-
#update_job_queue(params = {}) ⇒ Types::UpdateJobQueueResponse
Updates a job queue.
-
#update_scheduling_policy(params = {}) ⇒ Struct
Updates a scheduling policy.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Methods included from ClientStubs
#api_requests, #stub_data, #stub_responses
Methods inherited from Seahorse::Client::Base
add_plugin, api, clear_plugins, define, new, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
385 386 387 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 385 def initialize(*args) super end |
Instance Method Details
#cancel_job(params = {}) ⇒ Struct
Cancels a job in an Batch job queue. Jobs that are in the SUBMITTED
or PENDING
are canceled. A job inRUNNABLE
remains in RUNNABLE
until it reaches the head of the job queue. Then the job status is
updated to FAILED
.
PENDING
job is canceled after all dependency jobs are completed.
Therefore, it may take longer than expected to cancel a job in
PENDING
status.
When you try to cancel an array parent job in PENDING
, Batch
attempts to cancel all child jobs. The array parent job is canceled
when all child jobs are completed.
Jobs that progressed to the STARTING
or RUNNING
state aren't
canceled. However, the API operation still succeeds, even if no job is
canceled. These jobs must be terminated with the TerminateJob
operation.
446 447 448 449 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 446 def cancel_job(params = {}, = {}) req = build_request(:cancel_job, params) req.send_request() end |
#create_compute_environment(params = {}) ⇒ Types::CreateComputeEnvironmentResponse
Creates an Batch compute environment. You can create MANAGED
or
UNMANAGED
compute environments. MANAGED
compute environments can
use Amazon EC2 or Fargate resources. UNMANAGED
compute environments
can only use EC2 resources.
In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price.
In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide. After you created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide.
eks:DescribeCluster
.
Create a new compute environment with the new AMI.
Add the compute environment to an existing job queue.
Remove the earlier compute environment from your job queue.
Delete the earlier compute environment.
In April 2022, Batch added enhanced support for updating compute environments. For more information, see Updating compute environments. To use the enhanced updating of compute environments to update AMIs, follow these rules:
Either don't set the service role (
serviceRole
) parameter or set it to the AWSBatchServiceRole service-linked role.Set the allocation strategy (
allocationStrategy
) parameter toBEST_FIT_PROGRESSIVE
,SPOT_CAPACITY_OPTIMIZED
, orSPOT_PRICE_CAPACITY_OPTIMIZED
.Set the update to latest image version (
updateToLatestImageVersion
) parameter totrue
. TheupdateToLatestImageVersion
parameter is used when you update a compute environment. This parameter is ignored when you create a compute environment.Don't specify an AMI ID in
imageId
,imageIdOverride
(inec2Configuration
), or in the launch template (launchTemplate
). In that case, Batch selects the latest Amazon ECS optimized AMI that's supported by Batch at the time the infrastructure update is initiated. Alternatively, you can specify the AMI ID in theimageId
orimageIdOverride
parameters, or the launch template identified by theLaunchTemplate
properties. Changing any of these properties starts an infrastructure update. If the AMI ID is specified in the launch template, it can't be replaced by specifying an AMI ID in either theimageId
orimageIdOverride
parameters. It can only be replaced by specifying a different launch template, or if the launch template version is set to$Default
or$Latest
, by setting either a new default version for the launch template (if$Default
) or by adding a new version to the launch template (if$Latest
).
If these rules are followed, any update that starts an infrastructure
update causes the AMI ID to be re-selected. If the version
setting
in the launch template (launchTemplate
) is set to $Latest
or
$Default
, the latest or default version of the launch template is
evaluated up at the time of the infrastructure update, even if the
launchTemplate
wasn't updated.
827 828 829 830 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 827 def create_compute_environment(params = {}, = {}) req = build_request(:create_compute_environment, params) req.send_request() end |
#create_job_queue(params = {}) ⇒ Types::CreateJobQueueResponse
Creates an Batch job queue. When you create a job queue, you associate one or more compute environments to the queue and assign an order of preference for the compute environments.
You also set a priority to the job queue that determines the order that the Batch scheduler places jobs onto its associated compute environments. For example, if a compute environment is associated with more than one job queue, the job queue with a higher priority is given preference for scheduling jobs to that compute environment.
982 983 984 985 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 982 def create_job_queue(params = {}, = {}) req = build_request(:create_job_queue, params) req.send_request() end |
#create_scheduling_policy(params = {}) ⇒ Types::CreateSchedulingPolicyResponse
Creates an Batch scheduling policy.
1045 1046 1047 1048 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1045 def create_scheduling_policy(params = {}, = {}) req = build_request(:create_scheduling_policy, params) req.send_request() end |
#delete_compute_environment(params = {}) ⇒ Struct
Deletes an Batch compute environment.
Before you can delete a compute environment, you must set its state to
DISABLED
with the UpdateComputeEnvironment API operation and
disassociate it from any job queues with the UpdateJobQueue API
operation. Compute environments that use Fargate resources must
terminate all active jobs on that compute environment before deleting
the compute environment. If this isn't done, the compute environment
enters an invalid state.
1089 1090 1091 1092 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1089 def delete_compute_environment(params = {}, = {}) req = build_request(:delete_compute_environment, params) req.send_request() end |
#delete_job_queue(params = {}) ⇒ Struct
Deletes the specified job queue. You must first disable submissions for a queue with the UpdateJobQueue operation. All jobs in the queue are eventually terminated when you delete a job queue. The jobs are terminated at a rate of about 16 jobs each second.
It's not necessary to disassociate compute environments from a queue
before submitting a DeleteJobQueue
request.
1131 1132 1133 1134 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1131 def delete_job_queue(params = {}, = {}) req = build_request(:delete_job_queue, params) req.send_request() end |
#delete_scheduling_policy(params = {}) ⇒ Struct
Deletes the specified scheduling policy.
You can't delete a scheduling policy that's used in any job queues.
1155 1156 1157 1158 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1155 def delete_scheduling_policy(params = {}, = {}) req = build_request(:delete_scheduling_policy, params) req.send_request() end |
#deregister_job_definition(params = {}) ⇒ Struct
Deregisters an Batch job definition. Job definitions are permanently deleted after 180 days.
1192 1193 1194 1195 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1192 def deregister_job_definition(params = {}, = {}) req = build_request(:deregister_job_definition, params) req.send_request() end |
#describe_compute_environments(params = {}) ⇒ Types::DescribeComputeEnvironmentsResponse
Describes one or more of your compute environments.
If you're using an unmanaged compute environment, you can use the
DescribeComputeEnvironment
operation to determine the
ecsClusterArn
that you launch your Amazon ECS container instances
into.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1347 1348 1349 1350 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1347 def describe_compute_environments(params = {}, = {}) req = build_request(:describe_compute_environments, params) req.send_request() end |
#describe_job_definitions(params = {}) ⇒ Types::DescribeJobDefinitionsResponse
Describes a list of job definitions. You can specify a status
(such
as ACTIVE
) to only return job definitions that match that status.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1649 1650 1651 1652 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1649 def describe_job_definitions(params = {}, = {}) req = build_request(:describe_job_definitions, params) req.send_request() end |
#describe_job_queues(params = {}) ⇒ Types::DescribeJobQueuesResponse
Describes one or more of your job queues.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1749 1750 1751 1752 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 1749 def describe_job_queues(params = {}, = {}) req = build_request(:describe_job_queues, params) req.send_request() end |
#describe_jobs(params = {}) ⇒ Types::DescribeJobsResponse
Describes a list of Batch jobs.
2063 2064 2065 2066 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2063 def describe_jobs(params = {}, = {}) req = build_request(:describe_jobs, params) req.send_request() end |
#describe_scheduling_policies(params = {}) ⇒ Types::DescribeSchedulingPoliciesResponse
Describes one or more of your scheduling policies.
2101 2102 2103 2104 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2101 def describe_scheduling_policies(params = {}, = {}) req = build_request(:describe_scheduling_policies, params) req.send_request() end |
#list_jobs(params = {}) ⇒ Types::ListJobsResponse
Returns a list of Batch jobs.
You must specify only one of the following items:
A job queue ID to return a list of jobs in that job queue
A multi-node parallel job ID to return a list of nodes for that job
An array job ID to return a list of the children for that job
You can filter the results by job status with the jobStatus
parameter. If you don't specify a status, only RUNNING
jobs are
returned.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
2296 2297 2298 2299 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2296 def list_jobs(params = {}, = {}) req = build_request(:list_jobs, params) req.send_request() end |
#list_scheduling_policies(params = {}) ⇒ Types::ListSchedulingPoliciesResponse
Returns a list of Batch scheduling policies.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
2350 2351 2352 2353 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2350 def list_scheduling_policies(params = {}, = {}) req = build_request(:list_scheduling_policies, params) req.send_request() end |
#list_tags_for_resource(params = {}) ⇒ Types::ListTagsForResourceResponse
Lists the tags for an Batch resource. Batch resources that support tags are compute environments, jobs, job definitions, job queues, and scheduling policies. ARNs for child jobs of array and multi-node parallel (MNP) jobs aren't supported.
2404 2405 2406 2407 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2404 def (params = {}, = {}) req = build_request(:list_tags_for_resource, params) req.send_request() end |
#register_job_definition(params = {}) ⇒ Types::RegisterJobDefinitionResponse
Registers an Batch job definition.
2942 2943 2944 2945 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 2942 def register_job_definition(params = {}, = {}) req = build_request(:register_job_definition, params) req.send_request() end |
#submit_job(params = {}) ⇒ Types::SubmitJobResponse
Submits an Batch job from a job definition. Parameters that are
specified during SubmitJob override parameters defined in the job
definition. vCPU and memory requirements that are specified in the
resourceRequirements
objects in the job definition are the
exception. They can't be overridden this way using the memory
and
vcpus
parameters. Rather, you must specify updates to job definition
parameters in a resourceRequirements
object that's included in the
containerOverrides
parameter.
Jobs that run on Fargate resources can't be guaranteed to run for more than 14 days. This is because, after 14 days, Fargate resources might become unavailable and job might be terminated.
3237 3238 3239 3240 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3237 def submit_job(params = {}, = {}) req = build_request(:submit_job, params) req.send_request() end |
#tag_resource(params = {}) ⇒ Struct
Associates the specified tags to a resource with the specified
resourceArn
. If existing tags on a resource aren't specified in the
request parameters, they aren't changed. When a resource is deleted,
the tags that are associated with that resource are deleted as well.
Batch resources that support tags are compute environments, jobs, job
definitions, job queues, and scheduling policies. ARNs for child jobs
of array and multi-node parallel (MNP) jobs aren't supported.
3297 3298 3299 3300 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3297 def tag_resource(params = {}, = {}) req = build_request(:tag_resource, params) req.send_request() end |
#terminate_job(params = {}) ⇒ Struct
Terminates a job in a job queue. Jobs that are in the STARTING
or
RUNNING
state are terminated, which causes them to transition to
FAILED
. Jobs that have not progressed to the STARTING
state are
cancelled.
3342 3343 3344 3345 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3342 def terminate_job(params = {}, = {}) req = build_request(:terminate_job, params) req.send_request() end |
#untag_resource(params = {}) ⇒ Struct
Deletes specified tags from an Batch resource.
3388 3389 3390 3391 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3388 def untag_resource(params = {}, = {}) req = build_request(:untag_resource, params) req.send_request() end |
#update_compute_environment(params = {}) ⇒ Types::UpdateComputeEnvironmentResponse
Updates an Batch compute environment.
3565 3566 3567 3568 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3565 def update_compute_environment(params = {}, = {}) req = build_request(:update_compute_environment, params) req.send_request() end |
#update_job_queue(params = {}) ⇒ Types::UpdateJobQueueResponse
Updates a job queue.
3660 3661 3662 3663 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3660 def update_job_queue(params = {}, = {}) req = build_request(:update_job_queue, params) req.send_request() end |
#update_scheduling_policy(params = {}) ⇒ Struct
Updates a scheduling policy.
3695 3696 3697 3698 |
# File 'gems/aws-sdk-batch/lib/aws-sdk-batch/client.rb', line 3695 def update_scheduling_policy(params = {}, = {}) req = build_request(:update_scheduling_policy, params) req.send_request() end |