ListJobs
Returns a list of AWS 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.
Request Syntax
POST /v1/listjobs HTTP/1.1
Content-type: application/json
{
"arrayJobId": "string",
"filters": [
{
"name": "string",
"values": [ "string" ]
}
],
"jobQueue": "string",
"jobStatus": "string",
"maxResults": number,
"multiNodeJobId": "string",
"nextToken": "string"
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- arrayJobId
-
The job ID for an array job. Specifying an array job ID with this parameter lists all child jobs from within the specified array.
Type: String
Required: No
- filters
-
The filter to apply to the query. Only one filter can be used at a time. When the filter is used,
jobStatusis ignored. The filter doesn't apply to child jobs in an array or multi-node parallel (MNP) jobs. The results are sorted by thecreatedAtfield, with the most recent jobs being first.- JOB_NAME
-
The value of the filter is a case-insensitive match for the job name. If the value ends with an asterisk (*), the filter matches any job name that begins with the string before the '*'. This corresponds to the
jobNamevalue. For example,test1matches bothTest1andtest1, andtest1*matches bothtest1andTest10. When theJOB_NAMEfilter is used, the results are grouped by the job name and version. - JOB_DEFINITION
-
The value for the filter is the name or Amazon Resource Name (ARN) of the job definition. This corresponds to the
jobDefinitionvalue. The value is case sensitive. When the value for the filter is the job definition name, the results include all the jobs that used any revision of that job definition name. If the value ends with an asterisk (*), the filter matches any job definition name that begins with the string before the '*'. For example,jd1matches onlyjd1, andjd1*matches bothjd1andjd1A. The version of the job definition that's used doesn't affect the sort order. When theJOB_DEFINITIONfilter is used and the ARN is used (which is in the formarn:${Partition}:batch:${Region}:${Account}:job-definition/${JobDefinitionName}:${Revision}), the results include jobs that used the specified revision of the job definition. Asterisk (*) isn't supported when the ARN is used. - BEFORE_CREATED_AT
-
The value for the filter is the time that's before the job was created. This corresponds to the
createdAtvalue. The value is a string representation of the number of milliseconds since 00:00:00 UTC (midnight) on January 1, 1970. - AFTER_CREATED_AT
-
The value for the filter is the time that's after the job was created. This corresponds to the
createdAtvalue. The value is a string representation of the number of milliseconds since 00:00:00 UTC (midnight) on January 1, 1970.
Type: Array of KeyValuesPair objects
Required: No
- jobQueue
-
The name or full Amazon Resource Name (ARN) of the job queue used to list jobs.
Type: String
Required: No
- jobStatus
-
The job status used to filter jobs in the specified queue. If the
filtersparameter is specified, thejobStatusparameter is ignored and jobs with any status are returned. If you don't specify a status, onlyRUNNINGjobs are returned.Type: String
Valid Values:
SUBMITTED | PENDING | RUNNABLE | STARTING | RUNNING | SUCCEEDED | FAILEDRequired: No
- maxResults
-
The maximum number of results returned by
ListJobsin a paginated output. When this parameter is used,ListJobsreturns up tomaxResultsresults in a single page and anextTokenresponse element, if applicable. The remaining results of the initial request can be seen by sending anotherListJobsrequest with the returnednextTokenvalue.The following outlines key parameters and limitations:
-
The minimum value is 1.
-
When
--job-statusis used, AWS Batch returns up to 1000 values. -
When
--filtersis used, AWS Batch returns up to 100 values. -
If neither parameter is used, then
ListJobsreturns up to 1000 results (jobs that are in theRUNNINGstatus) and anextTokenvalue, if applicable.
Type: Integer
Required: No
-
- multiNodeJobId
-
The job ID for a multi-node parallel job. Specifying a multi-node parallel job ID with this parameter lists all nodes that are associated with the specified job.
Type: String
Required: No
- nextToken
-
The
nextTokenvalue returned from a previous paginatedListJobsrequest wheremaxResultswas used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned thenextTokenvalue. This value isnullwhen there are no more results to return.Note
Treat this token as an opaque identifier that's only used to retrieve the next items in a list and not for other programmatic purposes.
Type: String
Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"jobSummaryList": [
{
"arrayProperties": {
"index": number,
"size": number
},
"container": {
"exitCode": number,
"reason": "string"
},
"createdAt": number,
"jobArn": "string",
"jobDefinition": "string",
"jobId": "string",
"jobName": "string",
"nodeProperties": {
"isMainNode": boolean,
"nodeIndex": number,
"numNodes": number
},
"startedAt": number,
"status": "string",
"statusReason": "string",
"stoppedAt": number
}
],
"nextToken": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- jobSummaryList
-
A list of job summaries that match the request.
Type: Array of JobSummary objects
- nextToken
-
The
nextTokenvalue to include in a futureListJobsrequest. When the results of aListJobsrequest exceedmaxResults, this value can be used to retrieve the next page of results. This value isnullwhen there are no more results to return.Type: String
Errors
- ClientException
-
These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.
HTTP Status Code: 400
- ServerException
-
These errors are usually caused by a server issue.
HTTP Status Code: 500
Examples
In the following example or examples, the Authorization header contents
(
[authorization-params]
) must be replaced with an AWS Signature Version 4
signature. For more information about creating these signatures, see Signature Version 4 Signing Process in the
AWS
General Reference.
You only need to learn how to sign HTTP requests if you intend to manually create them. When you use the AWS Command Line Interface (AWS CLI)
Example
This example lists the running jobs in the HighPriority job queue.
Sample Request
POST /v1/listjobs HTTP/1.1
Host: batch.us-east-1.amazonaws.com
Accept-Encoding: identity
Content-Length: [content-length]
Authorization: [authorization-params]
X-Amz-Date: 20161129T201622Z
User-Agent: aws-cli/1.11.22 Python/2.7.12 Darwin/16.1.0 botocore/1.4.79
{
"jobQueue": "HighPriority"
}
Sample Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: [content-length]
Connection: keep-alive
Date: Tue, 29 Nov 2016 20:16:22 GMT
x-amzn-RequestId: [request-id]
X-Amzn-Trace-Id: [trace-id]
X-Cache: Miss from cloudfront
Via: 1.1 7f3f42df8af148df1f9f1ee7175987ad.cloudfront.net (CloudFront)
X-Amz-Cf-Id: idKR5mD8f7Luom03P9DV1bFGXsq_SIFNy_nMrTCOqZrRc0nXgHqZfg==
{
"jobSummaryList": [{
"jobId": "e66ff5fd-a1ff-4640-b1a2-0b0a142f49bb",
"jobName": "example"
}]
}
Example
This example lists jobs in the HighPriority job queue that are in the
SUBMITTED job status.
Sample Request
POST /v1/listjobs HTTP/1.1
Host: batch.us-east-1.amazonaws.com
Accept-Encoding: identity
Content-Length: [content-length]
Authorization: [authorization-params]
X-Amz-Date: 20161129T201642Z
User-Agent: aws-cli/1.11.22 Python/2.7.12 Darwin/16.1.0 botocore/1.4.79
{
"jobQueue": "HighPriority",
"jobStatus": "SUBMITTED"
}
Sample Response
HTTP/1.1 200 OK
Date: Tue, 29 Nov 2016 20:16:42 GMT
Content-Type: application/json
Content-Length: [content-length]
Connection: keep-alive
x-amzn-RequestId: [request-id]
X-Amzn-Trace-Id: [trace-id]
X-Cache: Miss from cloudfront
Via: 1.1 ebc28fb0ad14691ee5d6c1a49f41b878.cloudfront.net (CloudFront)
X-Amz-Cf-Id: Ngsjm0gBg2y4cDFG4uwpAmaKaT6Dejh7oGlVDmewQrUaeW_SPst_Bw==
{
"jobSummaryList": [{
"jobId": "68f0c163-fbd4-44e6-9fd1-25b14a434786",
"jobName": "example"
}]
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: