6.8 KiB
6.8 KiB
layout | page_title | sidebar_current | description |
---|---|---|---|
http | HTTP API: /v1/job | docs-http-job- | The '/1/job' endpoint is used for CRUD on a single job. |
/v1/job
The job
endpoint is used for CRUD on a single job. By default, the agent's local
region is used; another region can be specified using the ?region=
query parameter.
GET
- Description
- Query a single job for its specification and status.
- Method
- GET
- URL
- `/v1/job/`
- Parameters
- None
- Blocking Queries
- [Supported](/docs/http/index.html#blocking-queries)
- Returns
-
```javascript { "Region": "global", "ID": "binstore-storagelocker", "Name": "binstore-storagelocker", "Type": "service", "Priority": 50, "AllAtOnce": false, "Datacenters": [ "us2", "eu1" ], "Constraints": [ { "LTarget": "kernel.os", "RTarget": "windows", "Operand": "=", } ], "TaskGroups": [ { "Name": "binsl", "Count": 5, "Constraints": [ { "LTarget": "kernel.os", "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, "DynamicPorts": null } ] }, "Meta": null }, { "Name": "storagelocker", "Driver": "java", "Config": { "image": "hashicorp/storagelocker" }, "Constraints": [ { "LTarget": "kernel.arch", "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 } ```
- Description
- Query the allocations belonging to a single job.
- Method
- GET
- URL
- `/v1/job//allocations`
- Parameters
- None
- Blocking Queries
- [Supported](/docs/http/index.html#blocking-queries)
- Returns
-
```javascript [ { "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 }, ... ] ```
- Description
- Query the evaluations belonging to a single job.
- Method
- GET
- URL
- `/v1/job//evaluations`
- Parameters
- None
- Blocking Queries
- [Supported](/docs/http/index.html#blocking-queries)
- Returns
-
```javascript [ { "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 }, ... ] ```
PUT / POST
- Description
- Registers a new job or updates an existing job
- Method
- PUT or POST
- URL
- `/v1/job/`
- Parameters
-
- Job required 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.
- Returns
-
```javascript { "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", "EvalCreateIndex": 35, "JobModifyIndex": 34, } ```
- Description
- Creates a new evaluation for the given job. This can be used to force run the scheduling logic if necessary.
- Method
- PUT or POST
- URL
- `/v1/job//evaluate`
- Parameters
- None
- Returns
-
```javascript { "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", "EvalCreateIndex": 35, "JobModifyIndex": 34, } ```
DELETE
- Description
- Deregisters a job, and stops all allocations part of it.
- Method
- DELETE
- URL
- `/v1/job/`
- Parameters
- None
- Returns
-
```javascript { "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", "EvalCreateIndex": 35, "JobModifyIndex": 34, } ```