Skip to content

Commit 62e1ad2

Browse files
committed
make gen
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 1650818 commit 62e1ad2

File tree

10 files changed

+320
-97
lines changed

10 files changed

+320
-97
lines changed

coderd/apidoc/docs.go

Lines changed: 60 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 56 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/notifications.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
// @ID get-notifications-settings
2020
// @Security CoderSessionToken
2121
// @Produce json
22-
// @Tags General
22+
// @Tags Notifications
2323
// @Success 200 {object} codersdk.NotificationsSettings
2424
// @Router /notifications/settings [get]
2525
func (api *API) notificationsSettings(rw http.ResponseWriter, r *http.Request) {
@@ -51,7 +51,7 @@ func (api *API) notificationsSettings(rw http.ResponseWriter, r *http.Request) {
5151
// @Security CoderSessionToken
5252
// @Accept json
5353
// @Produce json
54-
// @Tags General
54+
// @Tags Notifications
5555
// @Param request body codersdk.NotificationsSettings true "Notifications settings request"
5656
// @Success 200 {object} codersdk.NotificationsSettings
5757
// @Success 304
@@ -121,6 +121,13 @@ func (api *API) putNotificationsSettings(rw http.ResponseWriter, r *http.Request
121121
httpapi.Write(r.Context(), rw, http.StatusOK, settings)
122122
}
123123

124+
// @Summary Get notification templates pertaining to system events
125+
// @ID system-notification-templates
126+
// @Security CoderSessionToken
127+
// @Produce json
128+
// @Tags Notifications
129+
// @Success 200 {array} codersdk.NotificationTemplate
130+
// @Router /notifications/templates/system [get]
124131
func (api *API) getSystemNotificationTemplates(rw http.ResponseWriter, r *http.Request) {
125132
ctx := r.Context()
126133

@@ -133,31 +140,23 @@ func (api *API) getSystemNotificationTemplates(rw http.ResponseWriter, r *http.R
133140
return
134141
}
135142

136-
out, err := convertNotificationTemplates(templates)
137-
if err != nil {
138-
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
139-
Message: "Failed to convert retrieved notifications templates to marshalable form.",
140-
Detail: err.Error(),
141-
})
142-
return
143-
}
144-
143+
out := convertNotificationTemplates(templates)
145144
httpapi.Write(r.Context(), rw, http.StatusOK, out)
146145
}
147146

148-
func convertNotificationTemplates(in []database.NotificationTemplate) (out []codersdk.NotificationTemplate, err error) {
147+
func convertNotificationTemplates(in []database.NotificationTemplate) (out []codersdk.NotificationTemplate) {
149148
for _, tmpl := range in {
150149
out = append(out, codersdk.NotificationTemplate{
151150
ID: tmpl.ID,
152151
Name: tmpl.Name,
153152
TitleTemplate: tmpl.TitleTemplate,
154153
BodyTemplate: tmpl.BodyTemplate,
155-
Actions: tmpl.Actions,
154+
Actions: string(tmpl.Actions),
156155
Group: tmpl.Group.String,
157156
Method: string(tmpl.Method.NotificationMethod),
158157
IsSystem: tmpl.IsSystem,
159158
})
160159
}
161160

162-
return out, nil
161+
return out
163162
}

codersdk/notifications.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ type NotificationTemplate struct {
2020
Name string `json:"name"`
2121
TitleTemplate string `json:"title_template"`
2222
BodyTemplate string `json:"body_template"`
23-
Actions []byte `json:"actions"`
23+
Actions string `json:"actions" format:""`
2424
Group string `json:"group"`
2525
Method string `json:"method"`
2626
IsSystem bool `json:"is_system"`
2727
}
2828

29+
// GetNotificationsSettings retrieves the notifications settings, which currently just describes whether all
30+
// notifications are paused from sending.
2931
func (c *Client) GetNotificationsSettings(ctx context.Context) (NotificationsSettings, error) {
3032
res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/settings", nil)
3133
if err != nil {
@@ -39,6 +41,8 @@ func (c *Client) GetNotificationsSettings(ctx context.Context) (NotificationsSet
3941
return settings, json.NewDecoder(res.Body).Decode(&settings)
4042
}
4143

44+
// PutNotificationsSettings modifies the notifications settings, which currently just controls whether all
45+
// notifications are paused from sending.
4246
func (c *Client) PutNotificationsSettings(ctx context.Context, settings NotificationsSettings) error {
4347
res, err := c.Request(ctx, http.MethodPut, "/api/v2/notifications/settings", settings)
4448
if err != nil {
@@ -55,6 +59,8 @@ func (c *Client) PutNotificationsSettings(ctx context.Context, settings Notifica
5559
return nil
5660
}
5761

62+
// UpdateNotificationTemplateMethod modifies a notification template to use a specific notification method, overriding
63+
// the method set in the deployment configuration.
5864
func (c *Client) UpdateNotificationTemplateMethod(ctx context.Context, notificationTemplateId uuid.UUID, method string) error {
5965
res, err := c.Request(ctx, http.MethodPost,
6066
fmt.Sprintf("/api/v2/notifications/templates/%s/method", notificationTemplateId),
@@ -74,6 +80,7 @@ func (c *Client) UpdateNotificationTemplateMethod(ctx context.Context, notificat
7480
return nil
7581
}
7682

83+
// GetSystemNotificationTemplates retrieves all notification templates pertaining to internal system events.
7784
func (c *Client) GetSystemNotificationTemplates(ctx context.Context) ([]NotificationTemplate, error) {
7885
res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/templates/system", nil)
7986
if err != nil {

docs/api/general.md

Lines changed: 0 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)