Skip to content

Commit ce8c7ea

Browse files
committed
Agents
1 parent 67a85b9 commit ce8c7ea

File tree

6 files changed

+202
-0
lines changed

6 files changed

+202
-0
lines changed

coderd/apidoc/docs.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,29 @@ const docTemplate = `{
10161016
}
10171017
}
10181018
},
1019+
"/workspaceagents/me/coordinate": {
1020+
"get": {
1021+
"security": [
1022+
{
1023+
"CoderSessionToken": []
1024+
}
1025+
],
1026+
"description": "It accepts a WebSocket connection to an agent that listens to\nincoming connections and publishes node updates.",
1027+
"produces": [
1028+
"application/json"
1029+
],
1030+
"tags": [
1031+
"Agents"
1032+
],
1033+
"summary": "Coordinate workspace agent via Tailnet",
1034+
"operationId": "get-workspace-agent-git-ssh-key-via-tailnet",
1035+
"responses": {
1036+
"101": {
1037+
"description": "Switching Protocols"
1038+
}
1039+
}
1040+
}
1041+
},
10191042
"/workspaceagents/me/gitauth": {
10201043
"get": {
10211044
"security": [
@@ -1060,6 +1083,34 @@ const docTemplate = `{
10601083
}
10611084
}
10621085
},
1086+
"/workspaceagents/me/gitsshkey": {
1087+
"get": {
1088+
"security": [
1089+
{
1090+
"CoderSessionToken": []
1091+
}
1092+
],
1093+
"consumes": [
1094+
"application/json"
1095+
],
1096+
"produces": [
1097+
"application/json"
1098+
],
1099+
"tags": [
1100+
"Agents"
1101+
],
1102+
"summary": "Get workspace agent Git SSH key",
1103+
"operationId": "get-workspace-agent-git-ssh-key",
1104+
"responses": {
1105+
"200": {
1106+
"description": "OK",
1107+
"schema": {
1108+
"$ref": "#/definitions/codersdk.AgentGitSSHKey"
1109+
}
1110+
}
1111+
}
1112+
}
1113+
},
10631114
"/workspaceagents/me/metadata": {
10641115
"get": {
10651116
"security": [
@@ -1706,6 +1757,17 @@ const docTemplate = `{
17061757
}
17071758
}
17081759
},
1760+
"codersdk.AgentGitSSHKey": {
1761+
"type": "object",
1762+
"properties": {
1763+
"private_key": {
1764+
"type": "string"
1765+
},
1766+
"public_key": {
1767+
"type": "string"
1768+
}
1769+
}
1770+
},
17091771
"codersdk.AgentStats": {
17101772
"type": "object",
17111773
"properties": {

coderd/apidoc/swagger.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,25 @@
882882
}
883883
}
884884
},
885+
"/workspaceagents/me/coordinate": {
886+
"get": {
887+
"security": [
888+
{
889+
"CoderSessionToken": []
890+
}
891+
],
892+
"description": "It accepts a WebSocket connection to an agent that listens to\nincoming connections and publishes node updates.",
893+
"produces": ["application/json"],
894+
"tags": ["Agents"],
895+
"summary": "Coordinate workspace agent via Tailnet",
896+
"operationId": "get-workspace-agent-git-ssh-key-via-tailnet",
897+
"responses": {
898+
"101": {
899+
"description": "Switching Protocols"
900+
}
901+
}
902+
}
903+
},
885904
"/workspaceagents/me/gitauth": {
886905
"get": {
887906
"security": [
@@ -920,6 +939,28 @@
920939
}
921940
}
922941
},
942+
"/workspaceagents/me/gitsshkey": {
943+
"get": {
944+
"security": [
945+
{
946+
"CoderSessionToken": []
947+
}
948+
],
949+
"consumes": ["application/json"],
950+
"produces": ["application/json"],
951+
"tags": ["Agents"],
952+
"summary": "Get workspace agent Git SSH key",
953+
"operationId": "get-workspace-agent-git-ssh-key",
954+
"responses": {
955+
"200": {
956+
"description": "OK",
957+
"schema": {
958+
"$ref": "#/definitions/codersdk.AgentGitSSHKey"
959+
}
960+
}
961+
}
962+
}
963+
},
923964
"/workspaceagents/me/metadata": {
924965
"get": {
925966
"security": [
@@ -1488,6 +1529,17 @@
14881529
}
14891530
}
14901531
},
1532+
"codersdk.AgentGitSSHKey": {
1533+
"type": "object",
1534+
"properties": {
1535+
"private_key": {
1536+
"type": "string"
1537+
},
1538+
"public_key": {
1539+
"type": "string"
1540+
}
1541+
}
1542+
},
14911543
"codersdk.AgentStats": {
14921544
"type": "object",
14931545
"properties": {

coderd/gitsshkey.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ func (api *API) gitSSHKey(rw http.ResponseWriter, r *http.Request) {
100100
})
101101
}
102102

103+
// @Summary Get workspace agent Git SSH key
104+
// @ID get-workspace-agent-git-ssh-key
105+
// @Security CoderSessionToken
106+
// @Accept json
107+
// @Produce json
108+
// @Tags Agents
109+
// @Success 200 {object} codersdk.AgentGitSSHKey
110+
// @Router /workspaceagents/me/gitsshkey [get]
103111
func (api *API) agentGitSSHKey(rw http.ResponseWriter, r *http.Request) {
104112
ctx := r.Context()
105113
agent := httpmw.WorkspaceAgent(r)

coderd/workspaceagents.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,15 @@ func (api *API) workspaceAgentConnection(rw http.ResponseWriter, r *http.Request
456456
})
457457
}
458458

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

docs/api/agents.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,29 @@ curl -X POST http://coder-server:8080/api/v2/workspaceagents/me/app-health \
180180

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

183+
## Coordinate workspace agent via Tailnet
184+
185+
### Code samples
186+
187+
```shell
188+
# Example request using curl
189+
curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/coordinate \
190+
-H 'Coder-Session-Token: API_KEY'
191+
```
192+
193+
`GET /workspaceagents/me/coordinate`
194+
195+
It accepts a WebSocket connection to an agent that listens to
196+
incoming connections and publishes node updates.
197+
198+
### Responses
199+
200+
| Status | Meaning | Description | Schema |
201+
| ------ | ------------------------------------------------------------------------ | ------------------- | ------ |
202+
| 101 | [Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2) | Switching Protocols | |
203+
204+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
205+
183206
## Get workspace agent Git auth
184207

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

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

246+
## Get workspace agent Git SSH key
247+
248+
### Code samples
249+
250+
```shell
251+
# Example request using curl
252+
curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/gitsshkey \
253+
-H 'Accept: application/json' \
254+
-H 'Coder-Session-Token: API_KEY'
255+
```
256+
257+
`GET /workspaceagents/me/gitsshkey`
258+
259+
### Example responses
260+
261+
> 200 Response
262+
263+
```json
264+
{
265+
"private_key": "string",
266+
"public_key": "string"
267+
}
268+
```
269+
270+
### Responses
271+
272+
| Status | Meaning | Description | Schema |
273+
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------ |
274+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.AgentGitSSHKey](schemas.md#codersdkagentgitsshkey) |
275+
276+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
277+
223278
## Get authorized workspace agent metadata
224279

225280
### Code samples

docs/api/schemas.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@
3232
| `document` | string | true | | |
3333
| `signature` | string | true | | |
3434

35+
## codersdk.AgentGitSSHKey
36+
37+
```json
38+
{
39+
"private_key": "string",
40+
"public_key": "string"
41+
}
42+
```
43+
44+
### Properties
45+
46+
| Name | Type | Required | Restrictions | Description |
47+
| ------------- | ------ | -------- | ------------ | ----------- |
48+
| `private_key` | string | false | | |
49+
| `public_key` | string | false | | |
50+
3551
## codersdk.AgentStats
3652

3753
```json

0 commit comments

Comments
 (0)