-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nia/docs 0.1.0-beta Co-authored-by: Kent 'picat' Gruber <kent@hashicorp.com> Co-authored-by: Lorna Song <lorna@hashicorp.com> Co-authored-by: John Eikenberry <jae@zhar.net>
- Loading branch information
1 parent
4b62213
commit 8e5fc47
Showing
15 changed files
with
444 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
layout: docs | ||
page_title: Consul-Terraform-Sync API | ||
sidebar_title: Overview | ||
description: >- | ||
How to use the Consul-Terraform-Sync API | ||
--- | ||
|
||
# Consul-Terraform-Sync API | ||
|
||
When running in [daemon mode](/docs/nia/cli#daemon-mode), Consul-Terraform-Sync serves an HTTP API interface. Details of the available API endpoints is available in the navigation to the left. | ||
|
||
### Port | ||
|
||
The API is served at the default port `8558` or a different port if set with [`port` configuration](/docs/nia/configuration#port) | ||
|
||
### Version Prefix | ||
|
||
All API routes are prefixed with `/v1/`. This documentation is for v1 of the API, which is the only version currently. | ||
|
||
Example: `localhost:8558/v1/status` | ||
|
||
### Error | ||
|
||
Successful API requests will receive a 2XX success status code. For other unsuccessful status codes, when possible, more details will be provided in a response body containing an error object. | ||
|
||
Example: Status 400 Bad Request | ||
```json | ||
{ | ||
"error": { | ||
"message": "example error message: unsupported status parameter value" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
layout: docs | ||
page_title: Consul-Terraform-Sync Tasks API | ||
sidebar_title: Tasks | ||
description: >- | ||
Consul-Terraform-Sync Tasks API | ||
--- | ||
# Tasks | ||
|
||
The `/tasks` endpoints modify the tasks that Consul-Terraform-Sync is responsible for running. | ||
|
||
## Update Task | ||
|
||
This endpoint allows patch updates to specifically supported fields for existing tasks. Currently only supports updating a task's [`enabled` value](/docs/nia/configuration#enabled-4). | ||
|
||
| Method | Path | Produces | | ||
| ------ | ------------------- | ------------------ | | ||
| `PATCH` | `/tasks/:task_name` | `application/json` | | ||
|
||
#### Request Parameters | ||
|
||
* `run` - (string) Values can be only be "inspect" and "now". | ||
* "inspect": Does not update the task but returns information on if/how resources would be changed for the proposed task update. | ||
* "now": Updates the task accordingly and immediately runs the task, rather than allowing the task to run at the natural daemon cadence | ||
|
||
#### Response Fields | ||
|
||
* `inspect` - Information on how resources would be changed given a proposed task update, similar to [inspect-mode](/docs/nia/cli/cli-overview#inspect-mode). This is only returned when passed the `run=inspect` request parameter | ||
* `changes_present` - (bool) Whether or not changes were detected for running the proposed task update | ||
* `plan` - (string) The Terraform plan generated for the proposed task update . Note: a non-empty string does not necessarily indicate changes were detected. | ||
|
||
|
||
#### Example: Disable a task | ||
|
||
Request: | ||
```shell-session | ||
$ curl --header "Content-Type: application/json" \ | ||
--request PATCH \ | ||
--data '{"enabled":false}' \ | ||
localhost:8558/v1/tasks/task_a | ||
``` | ||
|
||
Response: | ||
```json | ||
{} | ||
``` | ||
|
||
#### Example: Inspect enabling a task | ||
|
||
Request: | ||
```shell-session | ||
$ curl --header "Content-Type: application/json" \ | ||
--request PATCH \ | ||
--data '{"enabled":true}' \ | ||
localhost:8558/v1/tasks/task_a?run=inspect | ||
``` | ||
|
||
Response if no changes present: | ||
```json | ||
{ | ||
"changes_present": false, | ||
"plan": "No changes. Infrastructure is up-to-date. <truncated>" | ||
} | ||
``` | ||
|
||
Response if changes present: | ||
```json | ||
{ | ||
"changes_present": true, | ||
"plan": "<terraform plan truncated> Plan: 3 to add, 0 to change, 0 to destroy." | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.