Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f9aea9

Browse files
committed
docs: audit
1 parent 6c6c509 commit 9f9aea9

File tree

8 files changed

+5231
-300
lines changed

8 files changed

+5231
-300
lines changed

coderd/apidoc/docs.go

Lines changed: 924 additions & 89 deletions
Large diffs are not rendered by default.

coderd/apidoc/swagger.json

Lines changed: 919 additions & 101 deletions
Large diffs are not rendered by default.

coderd/audit.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ import (
2424
"github.com/coder/coder/codersdk"
2525
)
2626

27+
// @Summary Get audit logs
28+
// @ID get-audit-logs
29+
// @Security CoderSessionToken
30+
// @Produce json
31+
// @Tags Audit
32+
// @Param q query string true "Search query"
33+
// @Param after_id query string false "After ID" format(uuid)
34+
// @Param limit query int false "Page limit"
35+
// @Param offset query int false "Page offset"
36+
// @Success 200 {object} codersdk.AuditLogResponse
37+
// @Router /audit [get]
2738
func (api *API) auditLogs(rw http.ResponseWriter, r *http.Request) {
2839
ctx := r.Context()
2940
if !api.Authorize(r, rbac.ActionRead, rbac.ResourceAuditLog) {
@@ -77,6 +88,14 @@ func (api *API) auditLogs(rw http.ResponseWriter, r *http.Request) {
7788
})
7889
}
7990

91+
// @Summary Generate fake audit log
92+
// @ID generate-fake-audit-logs
93+
// @Security CoderSessionToken
94+
// @Accept json
95+
// @Tags Audit
96+
// @Param request body codersdk.CreateTestAuditLogRequest true "Audit log request"
97+
// @Success 204
98+
// @Router /audit/testgenerate [post]
8099
func (api *API) generateFakeAuditLog(rw http.ResponseWriter, r *http.Request) {
81100
ctx := r.Context()
82101
if !api.Authorize(r, rbac.ActionCreate, rbac.ResourceAuditLog) {

coderd/deploymentconfig.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import (
77
"github.com/coder/coder/coderd/rbac"
88
)
99

10+
// @Summary Get deployment config
11+
// @ID get-deployment-config
12+
// @Security CoderSessionToken
13+
// @Produce json
14+
// @Tags General
15+
// @Success 200 {object} codersdk.DeploymentConfig
16+
// @Router /config/deployment [get]
1017
func (api *API) deploymentConfig(rw http.ResponseWriter, r *http.Request) {
1118
if !api.Authorize(r, rbac.ActionRead, rbac.ResourceDeploymentConfig) {
1219
httpapi.Forbidden(rw)

docs/api/audit.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Audit
2+
3+
> This page is incomplete, stay tuned.
4+
5+
## Get audit logs
6+
7+
### Code samples
8+
9+
```shell
10+
# Example request using curl
11+
curl -X GET http://coder-server:8080/api/v2/audit?q=string \
12+
-H 'Accept: application/json' \
13+
-H 'Coder-Session-Token: API_KEY'
14+
```
15+
16+
`GET /audit`
17+
18+
### Parameters
19+
20+
| Name | In | Type | Required | Description |
21+
| ---------- | ----- | ------------ | -------- | ------------ |
22+
| `q` | query | string | true | Search query |
23+
| `after_id` | query | string(uuid) | false | After ID |
24+
| `limit` | query | integer | false | Page limit |
25+
| `offset` | query | integer | false | Page offset |
26+
27+
### Example responses
28+
29+
> 200 Response
30+
31+
```json
32+
{
33+
"audit_logs": [
34+
{
35+
"action": "string",
36+
"additional_fields": [0],
37+
"description": "string",
38+
"diff": {
39+
"property1": {
40+
"new": null,
41+
"old": null,
42+
"secret": true
43+
},
44+
"property2": {
45+
"new": null,
46+
"old": null,
47+
"secret": true
48+
}
49+
},
50+
"id": "string",
51+
"ip": {},
52+
"is_deleted": true,
53+
"organization_id": "string",
54+
"request_id": "string",
55+
"resource_icon": "string",
56+
"resource_id": "string",
57+
"resource_link": "string",
58+
"resource_target": "string",
59+
"resource_type": "string",
60+
"status_code": 0,
61+
"time": "string",
62+
"user": {
63+
"avatar_url": "string",
64+
"created_at": "string",
65+
"email": "string",
66+
"id": "string",
67+
"last_seen_at": "string",
68+
"organization_ids": ["string"],
69+
"roles": [
70+
{
71+
"display_name": "string",
72+
"name": "string"
73+
}
74+
],
75+
"status": "string",
76+
"username": "string"
77+
},
78+
"user_agent": "string"
79+
}
80+
],
81+
"count": 0
82+
}
83+
```
84+
85+
### Responses
86+
87+
| Status | Meaning | Description | Schema |
88+
| ------ | ------------------------------------------------------- | ----------- | ---------------------------------------------------------------- |
89+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.AuditLogResponse](schemas.md#codersdkauditlogresponse) |
90+
91+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
92+
93+
## Generate fake audit log
94+
95+
### Code samples
96+
97+
```shell
98+
# Example request using curl
99+
curl -X POST http://coder-server:8080/api/v2/audit/testgenerate \
100+
-H 'Content-Type: application/json' \
101+
-H 'Coder-Session-Token: API_KEY'
102+
```
103+
104+
`POST /audit/testgenerate`
105+
106+
> Body parameter
107+
108+
```json
109+
{
110+
"action": "string",
111+
"resource_id": "string",
112+
"resource_type": "string",
113+
"time": "string"
114+
}
115+
```
116+
117+
### Parameters
118+
119+
| Name | In | Type | Required | Description |
120+
| ------ | ---- | ---------------------------------------------------------------------------------- | -------- | ----------------- |
121+
| `body` | body | [codersdk.CreateTestAuditLogRequest](schemas.md#codersdkcreatetestauditlogrequest) | true | Audit log request |
122+
123+
### Responses
124+
125+
| Status | Meaning | Description | Schema |
126+
| ------ | --------------------------------------------------------------- | ----------- | ------ |
127+
| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content | |
128+
129+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

0 commit comments

Comments
 (0)