Files
coder/docs/admin/automation.md
T

32 lines
1.1 KiB
Markdown
Raw Normal View History

2022-10-12 10:43:59 -05:00
# Automation
We recommend automating Coder deployments through the CLI. Examples include [updating templates via CI/CD pipelines](../templates/change-management.md).
2023-01-04 19:14:47 +01:00
## Authentication
2022-10-12 10:43:59 -05:00
2023-01-04 19:14:47 +01:00
Coder uses authentication tokens to grant machine users access to the REST API. Follow the [Authentication](../api/authentication.md) page to learn how to generate long-lived tokens.
2022-10-12 10:43:59 -05:00
## CLI
You can use tokens with the CLI by setting the `--token` CLI flag or the `CODER_SESSION_TOKEN`
environment variable.
```console
2022-10-12 10:43:59 -05:00
export CODER_URL=https://coder.example.com
export CODER_SESSION_TOKEN=*****
coder workspaces ls
```
## REST API
2023-01-04 19:14:47 +01:00
You can review the [API reference](../api/index.md) to find the necessary routes and payload. Alternatively, you can enable the [Swagger](https://swagger.io/) endpoint to read the documentation and do requests against the API:
2022-10-12 10:43:59 -05:00
```console
2023-01-04 19:14:47 +01:00
coder server --swagger-enable
2022-10-12 10:43:59 -05:00
```
2023-01-04 19:14:47 +01:00
By default, the local Swagger endpoint is http://localhost:3000/swagger.
2022-10-12 10:43:59 -05:00
## Golang SDK
Coder publishes a public [Golang SDK](https://pkg.go.dev/github.com/coder/coder/codersdk) for Coder. This is consumed by the [CLI package](https://github.com/coder/coder/tree/main/cli).