Skip to content

Commit ffc1748

Browse files
committed
docs: Applications
1 parent a7e8f98 commit ffc1748

File tree

7 files changed

+217
-0
lines changed

7 files changed

+217
-0
lines changed

coderd/apidoc/docs.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,61 @@ const docTemplate = `{
2525
"host": "{{.Host}}",
2626
"basePath": "{{.BasePath}}",
2727
"paths": {
28+
"/applications/auth-redirect": {
29+
"get": {
30+
"security": [
31+
{
32+
"CoderSessionToken": []
33+
}
34+
],
35+
"produces": [
36+
"application/json"
37+
],
38+
"tags": [
39+
"Applications"
40+
],
41+
"summary": "Redirect to URI with encrypted API key",
42+
"operationId": "redirect-to-uri-with-encrypted-api-key",
43+
"parameters": [
44+
{
45+
"type": "string",
46+
"description": "Redirect destination",
47+
"name": "redirect_uri",
48+
"in": "query"
49+
}
50+
],
51+
"responses": {
52+
"307": {
53+
"description": "Temporary Redirect"
54+
}
55+
}
56+
}
57+
},
58+
"/applications/host": {
59+
"get": {
60+
"security": [
61+
{
62+
"CoderSessionToken": []
63+
}
64+
],
65+
"produces": [
66+
"application/json"
67+
],
68+
"tags": [
69+
"Applications"
70+
],
71+
"summary": "Get applications host",
72+
"operationId": "get-app-host",
73+
"responses": {
74+
"200": {
75+
"description": "OK",
76+
"schema": {
77+
"$ref": "#/definitions/codersdk.GetAppHostResponse"
78+
}
79+
}
80+
}
81+
}
82+
},
2883
"/organizations/{organization-id}/templates/": {
2984
"post": {
3085
"security": [
@@ -712,6 +767,15 @@ const docTemplate = `{
712767
}
713768
}
714769
},
770+
"codersdk.GetAppHostResponse": {
771+
"type": "object",
772+
"properties": {
773+
"host": {
774+
"description": "Host is the externally accessible URL for the Coder instance.",
775+
"type": "string"
776+
}
777+
}
778+
},
715779
"codersdk.Healthcheck": {
716780
"type": "object",
717781
"properties": {

coderd/apidoc/swagger.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,53 @@
1717
},
1818
"basePath": "/api/v2",
1919
"paths": {
20+
"/applications/auth-redirect": {
21+
"get": {
22+
"security": [
23+
{
24+
"CoderSessionToken": []
25+
}
26+
],
27+
"produces": ["application/json"],
28+
"tags": ["Applications"],
29+
"summary": "Redirect to URI with encrypted API key",
30+
"operationId": "redirect-to-uri-with-encrypted-api-key",
31+
"parameters": [
32+
{
33+
"type": "string",
34+
"description": "Redirect destination",
35+
"name": "redirect_uri",
36+
"in": "query"
37+
}
38+
],
39+
"responses": {
40+
"307": {
41+
"description": "Temporary Redirect"
42+
}
43+
}
44+
}
45+
},
46+
"/applications/host": {
47+
"get": {
48+
"security": [
49+
{
50+
"CoderSessionToken": []
51+
}
52+
],
53+
"produces": ["application/json"],
54+
"tags": ["Applications"],
55+
"summary": "Get applications host",
56+
"operationId": "get-app-host",
57+
"responses": {
58+
"200": {
59+
"description": "OK",
60+
"schema": {
61+
"$ref": "#/definitions/codersdk.GetAppHostResponse"
62+
}
63+
}
64+
}
65+
}
66+
},
2067
"/organizations/{organization-id}/templates/": {
2168
"post": {
2269
"security": [
@@ -635,6 +682,15 @@
635682
}
636683
}
637684
},
685+
"codersdk.GetAppHostResponse": {
686+
"type": "object",
687+
"properties": {
688+
"host": {
689+
"description": "Host is the externally accessible URL for the Coder instance.",
690+
"type": "string"
691+
}
692+
}
693+
},
638694
"codersdk.Healthcheck": {
639695
"type": "object",
640696
"properties": {

coderd/workspaceapps.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ var nonCanonicalHeaders = map[string]string{
5656
"Sec-Websocket-Version": "Sec-WebSocket-Version",
5757
}
5858

59+
// @Summary Get applications host
60+
// @ID get-app-host
61+
// @Security CoderSessionToken
62+
// @Produce json
63+
// @Tags Applications
64+
// @Success 200 {object} codersdk.GetAppHostResponse
65+
// @Router /applications/host [get]
5966
func (api *API) appHost(rw http.ResponseWriter, r *http.Request) {
6067
host := api.AppHostname
6168
if host != "" && api.AccessURL.Port() != "" {
@@ -484,6 +491,15 @@ func (api *API) verifyWorkspaceApplicationSubdomainAuth(rw http.ResponseWriter,
484491
return false
485492
}
486493

494+
// @Summary Redirect to URI with encrypted API key
495+
// @ID redirect-to-uri-with-encrypted-api-key
496+
// @Security CoderSessionToken
497+
// @Produce json
498+
// @Tags Applications
499+
// @Param redirect_uri query string false "Redirect destination"
500+
// @Success 307
501+
// @Router /applications/auth-redirect [get]
502+
//
487503
// workspaceApplicationAuth is an endpoint on the main router that handles
488504
// redirects from the subdomain handler.
489505
//

codersdk/workspaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ func (c *Client) WorkspaceByOwnerAndName(ctx context.Context, owner string, name
350350
}
351351

352352
type GetAppHostResponse struct {
353+
// Host is the externally accessible URL for the Coder instance.
353354
Host string `json:"host"`
354355
}
355356

docs/api/applications.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Applications
2+
3+
> This page is incomplete, stay tuned.
4+
5+
## Redirect to URI with encrypted API key
6+
7+
### Code samples
8+
9+
```shell
10+
# Example request using curl
11+
curl -X GET http://coder-server:8080/api/v2/applications/auth-redirect \
12+
-H 'Coder-Session-Token: API_KEY'
13+
14+
```
15+
16+
`GET /applications/auth-redirect`
17+
18+
### Parameters
19+
20+
| Name | In | Type | Required | Description |
21+
| ------------ | ----- | ------ | -------- | -------------------- |
22+
| redirect_uri | query | string | false | Redirect destination |
23+
24+
### Responses
25+
26+
| Status | Meaning | Description | Schema |
27+
| ------ | ----------------------------------------------------------------------- | ------------------ | --------- |
28+
| 307 | [Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) | Temporary Redirect | no schema |
29+
30+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
31+
32+
## Get applications host
33+
34+
### Code samples
35+
36+
```shell
37+
# Example request using curl
38+
curl -X GET http://coder-server:8080/api/v2/applications/host \
39+
-H 'Accept: application/json' \
40+
-H 'Coder-Session-Token: API_KEY'
41+
42+
```
43+
44+
`GET /applications/host`
45+
46+
### Example responses
47+
48+
> 200 Response
49+
50+
```json
51+
{
52+
"host": "string"
53+
}
54+
```
55+
56+
### Responses
57+
58+
| Status | Meaning | Description | Schema |
59+
| ------ | ------------------------------------------------------- | ----------- | -------------------------------------------------------------------- |
60+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.GetAppHostResponse](schemas.md#codersdkgetapphostresponse) |
61+
62+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

docs/api/schemas.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@
8484
| `latency_ms` | number | false | none | none |
8585
| `preferred` | boolean | false | none | none |
8686

87+
## codersdk.GetAppHostResponse
88+
89+
```json
90+
{
91+
"host": "string"
92+
}
93+
```
94+
95+
### Properties
96+
97+
| Name | Type | Required | Restrictions | Description |
98+
| ------ | ------ | -------- | ------------ | ------------------------------------------------------------- |
99+
| `host` | string | false | none | Host is the externally accessible URL for the Coder instance. |
100+
87101
## codersdk.Healthcheck
88102

89103
```json

docs/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@
329329
"title": "Authentication",
330330
"path": "./api/authentication.md"
331331
},
332+
{
333+
"title": "Applications",
334+
"path": "./api/applications.md"
335+
},
332336
{
333337
"title": "Templates",
334338
"path": "./api/templates.md"

0 commit comments

Comments
 (0)