2015-09-21 00:38:37 +00:00
|
|
|
---
|
|
|
|
layout: "http"
|
|
|
|
page_title: "HTTP API: /v1/job"
|
|
|
|
sidebar_current: "docs-http-job-"
|
|
|
|
description: |-
|
|
|
|
The '/1/job' endpoint is used for CRUD on a single job.
|
|
|
|
---
|
|
|
|
|
2015-10-30 21:38:51 +00:00
|
|
|
# /v1/job
|
2015-09-21 00:38:37 +00:00
|
|
|
|
2015-10-04 02:33:41 +00:00
|
|
|
The `job` endpoint is used for CRUD on a single job. By default, the agent's local
|
2015-09-21 00:38:37 +00:00
|
|
|
region is used; another region can be specified using the `?region=` query parameter.
|
|
|
|
|
|
|
|
## GET
|
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Query a single job for its specification and status.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>GET</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/v1/job/<id>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
2015-10-30 21:38:51 +00:00
|
|
|
<dt>Blocking Queries</dt>
|
|
|
|
<dd>
|
|
|
|
[Supported](/docs/http/index.html#blocking-queries)
|
|
|
|
</dd>
|
|
|
|
|
2015-09-21 00:38:37 +00:00
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"Region": "global",
|
|
|
|
"ID": "binstore-storagelocker",
|
|
|
|
"Name": "binstore-storagelocker",
|
|
|
|
"Type": "service",
|
|
|
|
"Priority": 50,
|
|
|
|
"AllAtOnce": false,
|
|
|
|
"Datacenters": [
|
|
|
|
"us2",
|
|
|
|
"eu1"
|
|
|
|
],
|
|
|
|
"Constraints": [
|
|
|
|
{
|
2016-02-05 00:50:20 +00:00
|
|
|
"LTarget": "${attr.kernel.os}",
|
2015-09-21 00:38:37 +00:00
|
|
|
"RTarget": "windows",
|
|
|
|
"Operand": "=",
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"TaskGroups": [
|
|
|
|
{
|
|
|
|
"Name": "binsl",
|
|
|
|
"Count": 5,
|
|
|
|
"Constraints": [
|
|
|
|
{
|
2016-02-05 00:50:20 +00:00
|
|
|
"LTarget": "${attr.kernel.os}",
|
2015-09-21 00:38:37 +00:00
|
|
|
"RTarget": "linux",
|
|
|
|
"Operand": "=",
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Tasks": [
|
|
|
|
{
|
|
|
|
"Name": "binstore",
|
|
|
|
"Driver": "docker",
|
|
|
|
"Config": {
|
|
|
|
"image": "hashicorp/binstore"
|
|
|
|
},
|
|
|
|
"Constraints": null,
|
|
|
|
"Resources": {
|
|
|
|
"CPU": 500,
|
|
|
|
"MemoryMB": 0,
|
|
|
|
"DiskMB": 0,
|
|
|
|
"IOPS": 0,
|
|
|
|
"Networks": [
|
|
|
|
{
|
|
|
|
"Device": "",
|
|
|
|
"CIDR": "",
|
|
|
|
"IP": "",
|
|
|
|
"MBits": 100,
|
|
|
|
"ReservedPorts": null,
|
2015-11-18 03:12:19 +00:00
|
|
|
"DynamicPorts": null
|
2015-09-21 00:38:37 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Meta": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "storagelocker",
|
|
|
|
"Driver": "java",
|
|
|
|
"Config": {
|
|
|
|
"image": "hashicorp/storagelocker"
|
|
|
|
},
|
|
|
|
"Constraints": [
|
|
|
|
{
|
2016-02-05 00:50:20 +00:00
|
|
|
"LTarget": "${attr.kernel.arch}",
|
2015-09-21 00:38:37 +00:00
|
|
|
"RTarget": "amd64",
|
|
|
|
"Operand": "=",
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Resources": {
|
|
|
|
"CPU": 500,
|
|
|
|
"MemoryMB": 0,
|
|
|
|
"DiskMB": 0,
|
|
|
|
"IOPS": 0,
|
|
|
|
"Networks": null
|
|
|
|
},
|
|
|
|
"Meta": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Meta": {
|
|
|
|
"elb_checks": "3",
|
|
|
|
"elb_interval": "10",
|
|
|
|
"elb_mode": "tcp"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Update": {
|
|
|
|
"Stagger": 0,
|
|
|
|
"MaxParallel": 0
|
|
|
|
},
|
|
|
|
"Meta": {
|
|
|
|
"foo": "bar"
|
|
|
|
},
|
|
|
|
"Status": "",
|
|
|
|
"StatusDescription": "",
|
|
|
|
"CreateIndex": 14,
|
|
|
|
"ModifyIndex": 14
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
Query the allocations belonging to a single job.
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>GET</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>`/v1/job/<id>/allocations`</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Blocking Queries</dt>
|
|
|
|
<dd>
|
|
|
|
[Supported](/docs/http/index.html#blocking-queries)
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
2015-10-30 21:38:51 +00:00
|
|
|
[
|
2015-09-21 00:38:37 +00:00
|
|
|
{
|
2015-10-30 21:38:51 +00:00
|
|
|
"ID": "3575ba9d-7a12-0c96-7b28-add168c67984",
|
|
|
|
"EvalID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
|
|
|
|
"Name": "binstore-storagelocker.binsl[0]",
|
|
|
|
"NodeID": "a703c3ca-5ff8-11e5-9213-970ee8879d1b",
|
|
|
|
"JobID": "binstore-storagelocker",
|
|
|
|
"TaskGroup": "binsl",
|
|
|
|
"DesiredStatus": "run",
|
|
|
|
"DesiredDescription": "",
|
|
|
|
"ClientStatus": "running",
|
|
|
|
"ClientDescription": "",
|
|
|
|
"CreateIndex": 16,
|
|
|
|
"ModifyIndex": 16
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
2015-09-21 00:38:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
Query the evaluations belonging to a single job.
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>GET</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>`/v1/job/<id>/evaluations`</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
2015-10-30 21:38:51 +00:00
|
|
|
<dt>Blocking Queries</dt>
|
|
|
|
<dd>
|
|
|
|
[Supported](/docs/http/index.html#blocking-queries)
|
|
|
|
</dd>
|
|
|
|
|
2015-09-21 00:38:37 +00:00
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
2015-10-30 21:38:51 +00:00
|
|
|
[
|
2015-09-21 00:38:37 +00:00
|
|
|
{
|
2015-10-30 21:38:51 +00:00
|
|
|
"ID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
|
|
|
|
"Priority": 50,
|
|
|
|
"Type": "service",
|
|
|
|
"TriggeredBy": "job-register",
|
|
|
|
"JobID": "binstore-storagelocker",
|
|
|
|
"JobModifyIndex": 14,
|
|
|
|
"NodeID": "",
|
|
|
|
"NodeModifyIndex": 0,
|
|
|
|
"Status": "complete",
|
|
|
|
"StatusDescription": "",
|
|
|
|
"Wait": 0,
|
|
|
|
"NextEval": "",
|
|
|
|
"PreviousEval": "",
|
|
|
|
"CreateIndex": 15,
|
|
|
|
"ModifyIndex": 17
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
2015-09-21 00:38:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-10-30 21:38:51 +00:00
|
|
|
## PUT / POST
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
Registers a new job or updates an existing job
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>PUT or POST</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>`/v1/job/<ID>`</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<span class="param">Job</span>
|
|
|
|
<span class="param-flags">required</span>
|
|
|
|
The JSON definition of the job. The general structure is given
|
|
|
|
by the [job specification](/docs/jobspec/index.html), and matches
|
|
|
|
the return response of GET.
|
|
|
|
</li>
|
|
|
|
</ul>
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
2015-10-30 21:38:51 +00:00
|
|
|
"EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
|
|
|
|
"EvalCreateIndex": 35,
|
|
|
|
"JobModifyIndex": 34,
|
|
|
|
}
|
2015-09-21 00:38:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-09-21 00:54:42 +00:00
|
|
|
Creates a new evaluation for the given job. This can be used to force
|
|
|
|
run the scheduling logic if necessary.
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2015-09-21 00:54:42 +00:00
|
|
|
<dd>PUT or POST</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-09-21 00:54:42 +00:00
|
|
|
<dd>`/v1/job/<ID>/evaluate`</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
2015-09-21 00:54:42 +00:00
|
|
|
"EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
|
|
|
|
"EvalCreateIndex": 35,
|
|
|
|
"JobModifyIndex": 34,
|
|
|
|
}
|
2015-09-21 00:38:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2016-01-19 19:09:36 +00:00
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Forces a new instance of the periodic job. A new instance will be created
|
|
|
|
even if it violates the job's
|
|
|
|
[`prohibit_overlap`](/docs/jobspec/index.html#prohibit_overlap) settings. As
|
|
|
|
such, this should be only used to immediately run a periodic job.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>PUT or POST</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/v1/job/<ID>/periodic/force`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"EvalCreateIndex": 7,
|
|
|
|
"EvalID": "57983ddd-7fcf-3e3a-fd24-f699ccfb36f4"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-10-30 21:38:51 +00:00
|
|
|
## DELETE
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dl>
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-10-30 21:38:51 +00:00
|
|
|
Deregisters a job, and stops all allocations part of it.
|
2015-09-21 00:38:37 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>DELETE</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-10-30 21:38:51 +00:00
|
|
|
<dd>`/v1/job/<ID>`</dd>
|
2015-09-21 00:38:37 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
2015-10-30 21:38:51 +00:00
|
|
|
"EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
|
|
|
|
"EvalCreateIndex": 35,
|
|
|
|
"JobModifyIndex": 34,
|
|
|
|
}
|
2015-09-21 00:38:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|