10000 docs: API users by mtojek · Pull Request #5620 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

docs: API users #5620

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 42 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a3fbe72
docs: audit, deploymentconfig, files, parameters
mtojek Dec 22, 2022
fbe1d70
Swagger comments in workspacebuilds.go
mtojek Jan 2, 2023
96daf47
structs in workspacebuilds.go
mtojek Jan 2, 2023
663ec87
workspaceagents: instance identity
mtojek Jan 2, 2023
fc00d7e
workspaceagents.go in progress
mtojek Jan 2, 2023
67a85b9
workspaceagents.go in progress
mtojek Jan 2, 2023
ce8c7ea
Agents
mtojek Jan 2, 2023
d2a9af5
workspacebuilds.go
mtojek Jan 2, 2023
f37c6b3
/workspaces
mtojek Jan 3, 2023
250982a
templates.go, templateversions.go
mtojek Jan 3, 2023
ff622a7
templateversion.go in progress
mtojek Jan 3, 2023
9dd385c
cancel
mtojek Jan 3, 2023
f96351a
templateversions
mtojek Jan 3, 2023
15de3b6
wip
mtojek Jan 3, 2023
596cdbd
Merge branch 'main' into 3522-workspacebuilds-1
mtojek Jan 3, 2023
eb4ba48
Merge
mtojek Jan 3, 2023
e314c24
x-apidocgen
mtojek Jan 4, 2023
97cd7ac
NullTime hack not needed anymore
mtojek Jan 4, 2023
ae06598
Fix: x-apidocgen
mtojek Jan 4, 2023
c82eb01
Merge branch '3522-workspacebuilds-1' into 3522-templates-1
mtojek Jan 4, 2023
77815d3
Merge branch '3522-templates-1' into 3522-organizations-1
mtojek Jan 4, 2023
7aa0f65
Members
mtojek Jan 4, 2023
b93398e
Fixes
mtojek Jan 4, 2023
5c96bd5
Fix
mtojek Jan 4, 2023
4667f07
WIP
mtojek Jan 5, 2023
0cd9c4a
Merge branch 'main' into 3522-templates-1
mtojek Jan 5, 2023
5405c0c
WIP
mtojek Jan 9, 2023
801cad1
Merge branch '3522-users-1' into 3522-organizations-1
mtojek Jan 9, 2023
0dc1d2a
Users
mtojek Jan 9, 2023
9285425
Logout
mtojek Jan 9, 2023
6979a7f
User profile
mtojek Jan 9, 2023
62a26f9
Status suspend activate
mtojek Jan 9, 2023
b1f389b
User roles
mtojek Jan 9, 2023
14a1654
User tokens
mtojek Jan 9, 2023
5c22629
Keys
mtojek Jan 9, 2023
91c78f4
SSH key
mtojek Jan 9, 2023
c06a636
All
mtojek Jan 9, 2023
ee6dbb1
Typo
mtojek Jan 9, 2023
8f22f8d
Fix
mtojek Jan 9, 2023
03ba246
Merge branch 'main' into 3522-organizations-1
mtojek Jan 11, 2023
1f12415
Fix
mtojek Jan 11, 2023
8773c10
Fix: LoginWithPasswordRequest
mtojek Jan 11, 2023
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
Keys
  • Loading branch information
mtojek committed Jan 9, 2023
commit 5c2262926f546d73b99fa167f3e15e26fa17fdda
79 changes: 79 additions & 0 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,85 @@ const docTemplate = `{
}
}
},
"/users/{user}/keys/{keyid}": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Get API key",
"operationId": "get-user-tokens",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"format": "uuid",
"description": "Key ID",
"name": "keyid",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.APIKey"
}
}
}
},
"delete": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Delete API key",
"operationId": "delete-user-tokens",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"format": "uuid",
"description": "Key ID",
"name": "keyid",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/users/{user}/password": {
"put": {
"security": [
Expand Down
71 changes: 71 additions & 0 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,77 @@
}
}
},
"/users/{user}/keys/{keyid}": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Users"],
"summary": "Get API key",
"operationId": "get-user-tokens",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"format": "uuid",
"description": "Key ID",
"name": "keyid",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.APIKey"
}
}
}
},
"delete": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Users"],
"summary": "Delete API key",
"operationId": "delete-user-tokens",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"format": "uuid",
"description": "Key ID",
"name": "keyid",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/users/{user}/password": {
"put": {
"security": [
Expand Down
18 changes: 18 additions & 0 deletions coderd/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ func (api *API) postAPIKey(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(ctx, rw, http.StatusCreated, codersdk.GenerateAPIKeyResponse{Key: cookie.Value})
}

// @Summary Get API key
// @ID get-user-tokens
// @Security CoderSessionToken
// @Produce json
// @Tags Users
// @Param user path string true "User ID, name, or me"
// @Param keyid path string true "Key ID" format(uuid)
// @Success 200 {object} codersdk.APIKey
// @Router /users/{user}/keys/{keyid} [get]
func (api *API) apiKey(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
Expand Down Expand Up 57AE @@ -199,6 +208,15 @@ func (api *API) tokens(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(ctx, rw, http.StatusOK, apiKeys)
}

// @Summary Delete API key
// @ID delete-user-tokens
// @Security CoderSessionToken
// @Produce json
// @Tags Users
// @Param user path string true "User ID, name, or me"
// @Param keyid path string true "Key ID" format(uuid)
// @Success 204
// @Router /users/{user}/keys/{keyid} [delete]
func (api *API) deleteAPIKey(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
Expand Down
73 changes: 73 additions & 0 deletions docs/api/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,79 @@ curl -X POST http://coder-server:8080/api/v2/users/{user}/keys/tokens \

To perform this operation, you must be authenticated. [Learn more](authentication.md).

## Get API key

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/keys/{keyid} \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```

`GET /users/{user}/keys/{keyid}`

### Parameters

| Name | In | Type | Required | Description |
| ------- | ---- | ------------ | -------- | -------------------- |
| `user` | path | string | true | User ID, name, or me |
| `keyid` | path | string(uuid) | true | Key ID |

### Example responses

> 200 Response

```json
{
"created_at": "2019-08-24T14:15:22Z",
"expires_at": "2019-08-24T14:15:22Z",
"id": "string",
"last_used": "2019-08-24T14:15:22Z",
"lifetime_seconds": 0,
"login_type": "password",
"scope": "all",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses

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

To perform this operation, you must be authenticated. [Learn more](authentication.md).

## Delete API key

### Code samples

```shell
# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/users/{user}/keys/{keyid} \
-H 'Coder-Session-Token: API_KEY'
```

`DELETE /users/{user}/keys/{keyid}`

### Parameters

| Name | In | Type | Required | Description |
| ------- | ---- | ------------ | -------- | -------------------- |
| `user` | path | string | true | User ID, name, or me |
| `keyid` | path | string(uuid) | true | Key ID |

### Responses

| Status | Meaning | Description | Schema |
| ------ | --------------------------------------------------------------- | ----------- | ------ |
| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content | |

To perform this operation, you must be authenticated. [Learn more](authentication.md).

## Update user password

### Code samples
Expand Down
0