feat: add notification preferences database & audit support (#14100)

This commit is contained in:
Danny Kopping
2024-08-05 16:18:45 +02:00
committed by GitHub
parent 49a2880abc
commit e164b1e71c
49 changed files with 3229 additions and 368 deletions

253
coderd/apidoc/docs.go generated
View File

@ -1547,6 +1547,34 @@ const docTemplate = `{
}
}
},
"/notifications/dispatch-methods": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Notifications"
],
"summary": "Get notification dispatch methods",
"operationId": "get-notification-dispatch-methods",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationMethodsResponse"
}
}
}
}
}
},
"/notifications/settings": {
"get": {
"security": [
@ -1558,7 +1586,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"General"
"Notifications"
],
"summary": "Get notifications settings",
"operationId": "get-notifications-settings",
@ -1584,7 +1612,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"General"
"Notifications"
],
"summary": "Update notifications settings",
"operationId": "update-notifications-settings",
@ -1612,6 +1640,68 @@ const docTemplate = `{
}
}
},
"/notifications/templates/system": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Notifications"
],
"summary": "Get system notification templates",
"operationId": "get-system-notification-templates",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationTemplate"
}
}
}
}
}
},
"/notifications/templates/{notification_template}/method": {
"put": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Enterprise"
],
"summary": "Update notification template dispatch method",
"operationId": "update-notification-template-dispatch-method",
"parameters": [
{
"type": "string",
"description": "Notification template UUID",
"name": "notification_template",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success"
},
"304": {
"description": "Not modified"
}
}
}
},
"/oauth2-provider/apps": {
"get": {
"security": [
@ -5354,6 +5444,90 @@ const docTemplate = `{
}
}
},
"/users/{user}/notifications/preferences": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Notifications"
],
"summary": "Get user notification preferences",
"operationId": "get-user-notification-preferences",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationPreference"
}
}
}
}
},
"put": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notifications"
],
"summary": "Update user notification preferences",
"operationId": "update-user-notification-preferences",
"parameters": [
{
"description": "Preferences",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.UpdateUserNotificationPreferences"
}
},
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationPreference"
}
}
}
}
}
},
"/users/{user}/organizations": {
"get": {
"security": [
@ -10202,6 +10376,66 @@ const docTemplate = `{
}
}
},
"codersdk.NotificationMethodsResponse": {
"type": "object",
"properties": {
"available": {
"type": "array",
"items": {
"type": "string"
}
},
"default": {
"type": "string"
}
}
},
"codersdk.NotificationPreference": {
"type": "object",
"properties": {
"disabled": {
"type": "boolean"
},
"id": {
"type": "string",
"format": "uuid"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"codersdk.NotificationTemplate": {
"type": "object",
"properties": {
"actions": {
"type": "string"
},
"body_template": {
"type": "string"
},
"group": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"kind": {
"type": "string"
},
"method": {
"type": "string"
},
"name": {
"type": "string"
},
"title_template": {
"type": "string"
}
}
},
"codersdk.NotificationsConfig": {
"type": "object",
"properties": {
@ -11217,6 +11451,8 @@ const docTemplate = `{
"file",
"group",
"license",
"notification_preference",
"notification_template",
"oauth2_app",
"oauth2_app_code_token",
"oauth2_app_secret",
@ -11245,6 +11481,8 @@ const docTemplate = `{
"ResourceFile",
"ResourceGroup",
"ResourceLicense",
"ResourceNotificationPreference",
"ResourceNotificationTemplate",
"ResourceOauth2App",
"ResourceOauth2AppCodeToken",
"ResourceOauth2AppSecret",
@ -12513,6 +12751,17 @@ const docTemplate = `{
}
}
},
"codersdk.UpdateUserNotificationPreferences": {
"type": "object",
"properties": {
"template_disabled_map": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
}
},
"codersdk.UpdateUserPasswordRequest": {
"type": "object",
"required": [

View File

@ -1344,6 +1344,30 @@
}
}
},
"/notifications/dispatch-methods": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Notifications"],
"summary": "Get notification dispatch methods",
"operationId": "get-notification-dispatch-methods",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationMethodsResponse"
}
}
}
}
}
},
"/notifications/settings": {
"get": {
"security": [
@ -1352,7 +1376,7 @@
}
],
"produces": ["application/json"],
"tags": ["General"],
"tags": ["Notifications"],
"summary": "Get notifications settings",
"operationId": "get-notifications-settings",
"responses": {
@ -1372,7 +1396,7 @@
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["General"],
"tags": ["Notifications"],
"summary": "Update notifications settings",
"operationId": "update-notifications-settings",
"parameters": [
@ -1399,6 +1423,60 @@
}
}
},
"/notifications/templates/system": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Notifications"],
"summary": "Get system notification templates",
"operationId": "get-system-notification-templates",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationTemplate"
}
}
}
}
}
},
"/notifications/templates/{notification_template}/method": {
"put": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Update notification template dispatch method",
"operationId": "update-notification-template-dispatch-method",
"parameters": [
{
"type": "string",
"description": "Notification template UUID",
"name": "notification_template",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success"
},
"304": {
"description": "Not modified"
}
}
}
},
"/oauth2-provider/apps": {
"get": {
"security": [
@ -4726,6 +4804,80 @@
}
}
},
"/users/{user}/notifications/preferences": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Notifications"],
"summary": "Get user notification preferences",
"operationId": "get-user-notification-preferences",
"parameters": [
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationPreference"
}
}
}
}
},
"put": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Notifications"],
"summary": "Update user notification preferences",
"operationId": "update-user-notification-preferences",
"parameters": [
{
"description": "Preferences",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.UpdateUserNotificationPreferences"
}
},
{
"type": "string",
"description": "User ID, name, or me",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.NotificationPreference"
}
}
}
}
}
},
"/users/{user}/organizations": {
"get": {
"security": [
@ -9143,6 +9295,66 @@
}
}
},
"codersdk.NotificationMethodsResponse": {
"type": "object",
"properties": {
"available": {
"type": "array",
"items": {
"type": "string"
}
},
"default": {
"type": "string"
}
}
},
"codersdk.NotificationPreference": {
"type": "object",
"properties": {
"disabled": {
"type": "boolean"
},
"id": {
"type": "string",
"format": "uuid"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"codersdk.NotificationTemplate": {
"type": "object",
"properties": {
"actions": {
"type": "string"
},
"body_template": {
"type": "string"
},
"group": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"kind": {
"type": "string"
},
"method": {
"type": "string"
},
"name": {
"type": "string"
},
"title_template": {
"type": "string"
}
}
},
"codersdk.NotificationsConfig": {
"type": "object",
"properties": {
@ -10119,6 +10331,8 @@
"file",
"group",
"license",
"notification_preference",
"notification_template",
"oauth2_app",
"oauth2_app_code_token",
"oauth2_app_secret",
@ -10147,6 +10361,8 @@
"ResourceFile",
"ResourceGroup",
"ResourceLicense",
"ResourceNotificationPreference",
"ResourceNotificationTemplate",
"ResourceOauth2App",
"ResourceOauth2AppCodeToken",
"ResourceOauth2AppSecret",
@ -11362,6 +11578,17 @@
}
}
},
"codersdk.UpdateUserNotificationPreferences": {
"type": "object",
"properties": {
"template_disabled_map": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
}
},
"codersdk.UpdateUserPasswordRequest": {
"type": "object",
"required": ["password"],