Skip to content

docs: API workspace agents and builds #5538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Agents
  • Loading branch information
mtojek committed Jan 2, 2023
commit ce8c7eacbbc72c97b8e7db96cd4092495c30b08f
62 changes: 62 additions & 0 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,29 @@ const docTemplate = `{
}
}
},
"/workspaceagents/me/coordinate": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"description": "It accepts a WebSocket connection to an agent that listens to\nincoming connections and publishes node updates.",
"produces": [
"application/json"
],
"tags": [
"Agents"
],
"summary": "Coordinate workspace agent via Tailnet",
"operationId": "get-workspace-agent-git-ssh-key-via-tailnet",
"responses": {
"101": {
"description": "Switching Protocols"
}
}
}
},
"/workspaceagents/me/gitauth": {
"get": {
"security": [
Expand Down Expand Up @@ -1060,6 +1083,34 @@ const docTemplate = `{
}
}
},
"/workspaceagents/me/gitsshkey": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Agents"
],
"summary": "Get workspace agent Git SSH key",
"operationId": "get-workspace-agent-git-ssh-key",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.AgentGitSSHKey"
}
}
}
}
},
"/workspaceagents/me/metadata": {
"get": {
"security": [
Expand Down Expand Up @@ -1706,6 +1757,17 @@ const docTemplate = `{
}
}
},
"codersdk.AgentGitSSHKey": {
"type": "object",
"properties": {
"private_key": {
"type": "string"
},
"public_key": {
"type": "string"
}
}
},
"codersdk.AgentStats": {
"type": "object",
"properties": {
Expand Down
52 changes: 52 additions & 0 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,25 @@
}
}
},
"/workspaceagents/me/coordinate": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"description": "It accepts a WebSocket connection to an agent that listens to\nincoming connections and publishes node updates.",
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Coordinate workspace agent via Tailnet",
"operationId": "get-workspace-agent-git-ssh-key-via-tailnet",
"responses": {
"101": {
"description": "Switching Protocols"
}
}
}
},
"/workspaceagents/me/gitauth": {
"get": {
"security": [
Expand Down Expand Up @@ -920,6 +939,28 @@
}
}
},
"/workspaceagents/me/gitsshkey": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Get workspace agent Git SSH key",
"operationId": "get-workspace-agent-git-ssh-key",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.AgentGitSSHKey"
}
}
}
}
},
"/workspaceagents/me/metadata": {
"get": {
"security": [
Expand Down Expand Up @@ -1488,6 +1529,17 @@
}
}
},
"codersdk.AgentGitSSHKey": {
"type": "object",
"properties": {
"private_key": {
"type": "string"
},
"public_key": {
"type": "string"
}
}
},
"codersdk.AgentStats": {
"type": "object",
"properties": {
Expand Down
8 changes: 8 additions & 0 deletions coderd/gitsshkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ func (api *API) gitSSHKey(rw http.ResponseWriter, r *http.Request) {
})
}

// @Summary Get workspace agent Git SSH key
// @ID get-workspace-agent-git-ssh-key
// @Security CoderSessionToken
// @Accept json
// @Produce json
// @Tags Agents
// @Success 200 {object} codersdk.AgentGitSSHKey
// @Router /workspaceagents/me/gitsshkey [get]
func (api *API) agentGitSSHKey(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
agent := httpmw.WorkspaceAgent(r)
Expand Down
9 changes: 9 additions & 0 deletions coderd/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,15 @@ func (api *API) workspaceAgentConnection(rw http.ResponseWriter, r *http.Request
})
}

// @Summary Coordinate workspace agent via Tailnet
// @Description It accepts a WebSocket connection to an agent that listens to
// @Description incoming connections and publishes node updates.
// @ID get-workspace-agent-git-ssh-key-via-tailnet
// @Security CoderSessionToken
// @Produce json
// @Tags Agents
// @Success 101
// @Router /workspaceagents/me/coordinate [get]
func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down
55 changes: 55 additions & 0 deletions docs/api/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,29 @@ curl -X POST http://coder-server:8080/api/v2/workspaceagents/me/app-health \

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

## Coordinate workspace agent via Tailnet

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/coordinate \
-H 'Coder-Session-Token: API_KEY'
```

`GET /workspaceagents/me/coordinate`

It accepts a WebSocket connection to an agent that listens to
incoming connections and publishes node updates.

### Responses

| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------------------------ | ------------------- | ------ |
| 101 | [Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2) | Switching Protocols | |

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

## Get workspace agent Git auth

### Code samples
Expand Down Expand Up @@ -220,6 +243,38 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/gitauth?url=http%

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

## Get workspace agent Git SSH key

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/gitsshkey \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```

`GET /workspaceagents/me/gitsshkey`

### Example responses

> 200 Response

```json
{
"private_key": "string",
"public_key": "string"
}
```

### Responses

| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------ |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.AgentGitSSHKey](schemas.md#codersdkagentgitsshkey) |

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

## Get authorized workspace agent metadata

### Code samples
Expand Down
16 changes: 16 additions & 0 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@
| `document` | string | true | | |
| `signature` | string | true | | |

## codersdk.AgentGitSSHKey

```json
{
"private_key": "string",
"public_key": "string"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ------------- | ------ | -------- | ------------ | ----------- |
| `private_key` | string | false | | |
| `public_key` | string | false | | |

## codersdk.AgentStats

```json
Expand Down