From 80e296bbc56fcd7e8c2191f1f6e8aa33759c03e5 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 26 May 2017 19:17:59 -0400 Subject: [PATCH] Migrate validate APIs --- website/source/api/validate.html.md | 64 +++++++ website/source/docs/http/validate.html.md | 209 ---------------------- 2 files changed, 64 insertions(+), 209 deletions(-) create mode 100644 website/source/api/validate.html.md delete mode 100644 website/source/docs/http/validate.html.md diff --git a/website/source/api/validate.html.md b/website/source/api/validate.html.md new file mode 100644 index 000000000..76d5f586b --- /dev/null +++ b/website/source/api/validate.html.md @@ -0,0 +1,64 @@ +--- +layout: api +page_title: Validate - HTTP API +sidebar_current: api-validate +description: |- + The /validate endpoints are used to validate object structs, fields, and + types. +--- + +# Validate HTTP API + +The `/validate` endpoints are used to validate object structs, fields, and +types. + +## Validate Job + +This endpoint validates a Nomad job file. The local Nomad agent forwards the +request to a server. In the event a server can't be reached the agent verifies +the job file locally but skips validating driver configurations. + +~> This endpoint accepts a **JSON job file**, not an HCL job file. + +| Method | Path | Produces | +| ------- | ------------------------- | -------------------------- | +| `POST` | `/v1/validate/job` | `application/json` | + +The table below shows this endpoint's support for +[blocking queries](/api/index.html#blocking-queries), +[consistency modes](/api/index.html#consistency-modes), and +[required ACLs](/api/index.html#acls). + +| Blocking Queries | Consistency Modes | ACL Required | +| ---------------- | ----------------- | ------------ | +| `NO` | `none` | `none` | + +### Parameters + +There are no parameters, but the request _body_ contains the entire job file. + +### Sample Payload + +```text +(any valid nomad job IN JSON FORMAT) +``` + +### Sample Request + +```text +$ curl \ + --request POST \ + --data @my-job.nomad \ + https://nomad.rocks/v1/validate/job +``` + +### Sample Response +```json +{ + "DriverConfigValidated": true, + "ValidationErrors": [ + "Task group cache validation failed: 1 error(s) occurred:\n\n* Task redis validation failed: 1 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* minimum CPU value is 20; got 1" + ], + "Error": "1 error(s) occurred:\n\n* Task group cache validation failed: 1 error(s) occurred:\n\n* Task redis validation failed: 1 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* minimum CPU value is 20; got 1" +} +``` diff --git a/website/source/docs/http/validate.html.md b/website/source/docs/http/validate.html.md deleted file mode 100644 index 6e55053b8..000000000 --- a/website/source/docs/http/validate.html.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -layout: "http" -page_title: "HTTP API: /v1/validate/" -sidebar_current: "docs-http-validate" -description: |- - The '/1/validate/' endpoints are used to for validation of objects. ---- - -# /v1/validate/job - -The `/validate/job` endpoint is to validate a Nomad job file. The local Nomad -agent forwards the request to a server. In the event a server can't be -reached the agent verifies the job file locally but skips validating driver -configurations. - -## POST - -
-
Description
-
- Validates a Nomad job file -
- -
Method
-
POST
- -
URL
-
`/v1/validate/job`
- -
Parameters
-
- None -
-
Body
-
- - ```javascript -{ - "Job": { - "Region": "global", - "ID": "example", - "ParentID": null, - "Name": "example", - "Type": "service", - "Priority": 50, - "AllAtOnce": null, - "Datacenters": [ - "dc1" - ], - "Constraints": null, - "TaskGroups": [ - { - "Name": "cache", - "Count": 1, - "Constraints": null, - "Tasks": [ - { - "Name": "mongo", - "Driver": "exec", - "User": "", - "Config": { - "args": [ - "-l", - "127.0.0.1", - "0" - ], - "command": "/bin/nc" - }, - "Constraints": null, - "Env": null, - "Services": null, - "Resources": { - "CPU": 1, - "MemoryMB": 10, - "DiskMB": null, - "IOPS": 0, - "Networks": [ - { - "Public": false, - "CIDR": "", - "ReservedPorts": null, - "DynamicPorts": [ - { - "Label": "db111", - "Value": 0 - }, - { - "Label": "http111", - "Value": 0 - } - ], - "IP": "", - "MBits": 10 - } - ] - }, - "Meta": null, - "KillTimeout": null, - "LogConfig": { - "MaxFiles": 10, - "MaxFileSizeMB": 10 - }, - "Artifacts": null, - "Vault": null, - "Templates": null, - "DispatchPayload": null - }, - { - "Name": "redis", - "Driver": "raw_exec", - "User": "", - "Config": { - "args": [ - "-l", - "127.0.0.1", - "0" - ], - "command": "/usr/bin/nc" - }, - "Constraints": null, - "Env": null, - "Services": null, - "Resources": { - "CPU": 1, - "MemoryMB": 10, - "DiskMB": null, - "IOPS": 0, - "Networks": [ - { - "Public": false, - "CIDR": "", - "ReservedPorts": null, - "DynamicPorts": [ - { - "Label": "db", - "Value": 0 - }, - { - "Label": "http", - "Value": 0 - } - ], - "IP": "", - "MBits": 10 - } - ] - }, - "Meta": null, - "KillTimeout": null, - "LogConfig": { - "MaxFiles": 10, - "MaxFileSizeMB": 10 - }, - "Artifacts": null, - "Vault": null, - "Templates": null, - "DispatchPayload": null - } - ], - "RestartPolicy": { - "Interval": 300000000000, - "Attempts": 10, - "Delay": 25000000000, - "Mode": "delay" - }, - "EphemeralDisk": { - "Sticky": null, - "Migrate": null, - "SizeMB": 300 - }, - "Meta": null - } - ], - "Update": { - "Stagger": 10000000000, - "MaxParallel": 0 - }, - "Periodic": null, - "ParameterizedJob": null, - "Payload": null, - "Meta": null, - "VaultToken": null, - "Status": null, - "StatusDescription": null, - "CreateIndex": null, - "ModifyIndex": null, - "JobModifyIndex": null - } -} - ``` - -
- - -
Returns
-
- - ```javascript -{ - "DriverConfigValidated": true, - "ValidationErrors": [ - "Task group cache validation failed: 1 error(s) occurred:\n\n* Task redis validation failed: 1 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* minimum CPU value is 20; got 1" - ], - "Error": "1 error(s) occurred:\n\n* Task group cache validation failed: 1 error(s) occurred:\n\n* Task redis validation failed: 1 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* minimum CPU value is 20; got 1" -} - ``` - -
-