feat: add organization details to audit log response (#13961)

* Allow creating test audits with nil org

Not all audit entries have organization IDs, so this will allow us to
test those cases.

* Add organization details to audit log queries

* Add organization to audit log response

This replaces the old ID.  This is a breaking change but organizations
were not being used before.
This commit is contained in:
Asher
2024-07-22 13:28:44 -08:00
committed by GitHub
parent 38c7dcda94
commit a8e6e89f65
16 changed files with 348 additions and 120 deletions
+6
View File
@@ -47,6 +47,12 @@ curl -X GET http://coder-server:8080/api/v2/audit?limit=0 \
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"ip": "string",
"is_deleted": true,
"organization": {
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string"
},
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"resource_icon": "string",
+53 -20
View File
@@ -558,6 +558,12 @@
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"ip": "string",
"is_deleted": true,
"organization": {
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string"
},
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"resource_icon": "string",
@@ -594,26 +600,27 @@
### Properties
| Name | Type | Required | Restrictions | Description |
| ------------------- | ---------------------------------------------- | -------- | ------------ | -------------------------------------------- |
| `action` | [codersdk.AuditAction](#codersdkauditaction) | false | | |
| `additional_fields` | array of integer | false | | |
| `description` | string | false | | |
| `diff` | [codersdk.AuditDiff](#codersdkauditdiff) | false | | |
| `id` | string | false | | |
| `ip` | string | false | | |
| `is_deleted` | boolean | false | | |
| `organization_id` | string | false | | |
| `request_id` | string | false | | |
| `resource_icon` | string | false | | |
| `resource_id` | string | false | | |
| `resource_link` | string | false | | |
| `resource_target` | string | false | | Resource target is the name of the resource. |
| `resource_type` | [codersdk.ResourceType](#codersdkresourcetype) | false | | |
| `status_code` | integer | false | | |
| `time` | string | false | | |
| `user` | [codersdk.User](#codersdkuser) | false | | |
| `user_agent` | string | false | | |
| Name | Type | Required | Restrictions | Description |
| ------------------- | ------------------------------------------------------------ | -------- | ------------ | -------------------------------------------- |
| `action` | [codersdk.AuditAction](#codersdkauditaction) | false | | |
| `additional_fields` | array of integer | false | | |
| `description` | string | false | | |
| `diff` | [codersdk.AuditDiff](#codersdkauditdiff) | false | | |
| `id` | string | false | | |
| `ip` | string | false | | |
| `is_deleted` | boolean | false | | |
| `organization` | [codersdk.MinimalOrganization](#codersdkminimalorganization) | false | | |
| `organization_id` | string | false | | Deprecated: Use 'organization.id' instead. |
| `request_id` | string | false | | |
| `resource_icon` | string | false | | |
| `resource_id` | string | false | | |
| `resource_link` | string | false | | |
| `resource_target` | string | false | | Resource target is the name of the resource. |
| `resource_type` | [codersdk.ResourceType](#codersdkresourcetype) | false | | |
| `status_code` | integer | false | | |
| `time` | string | false | | |
| `user` | [codersdk.User](#codersdkuser) | false | | |
| `user_agent` | string | false | | |
## codersdk.AuditLogResponse
@@ -639,6 +646,12 @@
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"ip": "string",
"is_deleted": true,
"organization": {
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string"
},
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"resource_icon": "string",
@@ -3078,6 +3091,26 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| --------------- | ------ | -------- | ------------ | ----------- |
| `session_token` | string | true | | |
## codersdk.MinimalOrganization
```json
{
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| -------------- | ------ | -------- | ------------ | ----------- |
| `display_name` | string | false | | |
| `icon` | string | false | | |
| `id` | string | true | | |
| `name` | string | false | | |
## codersdk.MinimalUser
```json