Merge pull request #4138 from hashicorp/i-hcl-json-endpoint

HCL to JSON api endpoint
This commit is contained in:
Nick Ethier
2018-04-19 14:18:34 -04:00
committed by GitHub
8 changed files with 229 additions and 0 deletions

View File

@@ -231,6 +231,83 @@ $ curl \
}
```
## Parse Job
This endpoint will parse a HCL jobspec and produce the equivalent JSON encoded
job.
| Method | Path | Produces |
| ------ | ------------------------- | -------------------------- |
| `POST` | `/v1/jobs/parse` | `application/json` |
The table below shows this endpoint's support for
[blocking queries](/api/index.html#blocking-queries) and
[required ACLs](/api/index.html#acls).
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `none` |
### Parameters
- `JobHCL` `(string: <required>)` - Specifies the HCL definition of the job
encoded in a JSON string.
- `Canonicalize` `(bool: false)` - Flag to enable setting any unset fields to
their default values.
## Sample Payload
```json
{
"JobHCL":"job \"example\" { type = \"service\" group \"cache\" {} }",
"Canonicalize": true
}
```
### Sample Request
```text
$ curl \
--request POST \
--data '{"Canonicalize": true, "JobHCL": "job \"my-job\" {}"}' \
https://localhost:4646/v1/jobs/parse
```
### Sample Response
```json
{
"AllAtOnce": false,
"Constraints": null,
"CreateIndex": 0,
"Datacenters": null,
"ID": "my-job",
"JobModifyIndex": 0,
"Meta": null,
"Migrate": null,
"ModifyIndex": 0,
"Name": "my-job",
"Namespace": "default",
"ParameterizedJob": null,
"ParentID": "",
"Payload": null,
"Periodic": null,
"Priority": 50,
"Region": "global",
"Reschedule": null,
"Stable": false,
"Status": "",
"StatusDescription": "",
"Stop": false,
"SubmitTime": null,
"TaskGroups": null,
"Type": "service",
"Update": null,
"VaultToken": "",
"Version": 0
}
```
## Read Job
This endpoint reads information about a single job for its specification and