Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit922a464

Browse files
committed
make gen
Signed-off-by: Danny Kopping <danny@coder.com>
1 parenta145af0 commit922a464

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 aboutcustomizing 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 aboutcustomizing 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-
// @TagsGeneral
22+
// @TagsNotifications
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-
// @TagsGeneral
54+
// @TagsNotifications
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-
iferr!=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-
funcconvertNotificationTemplates(in []database.NotificationTemplate) (out []codersdk.NotificationTemplate,errerror) {
147+
funcconvertNotificationTemplates(in []database.NotificationTemplate) (out []codersdk.NotificationTemplate) {
149148
for_,tmpl:=rangein {
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-
returnout,nil
161+
returnout
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
Namestring`json:"name"`
2121
TitleTemplatestring`json:"title_template"`
2222
BodyTemplatestring`json:"body_template"`
23-
Actions[]byte`json:"actions"`
23+
Actionsstring`json:"actions" format:""`
2424
Groupstring`json:"group"`
2525
Methodstring`json:"method"`
2626
IsSystembool`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
iferr!=nil {
@@ -39,6 +41,8 @@ func (c *Client) GetNotificationsSettings(ctx context.Context) (NotificationsSet
3941
returnsettings,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,settingsNotificationsSettings)error {
4347
res,err:=c.Request(ctx,http.MethodPut,"/api/v2/notifications/settings",settings)
4448
iferr!=nil {
@@ -55,6 +59,8 @@ func (c *Client) PutNotificationsSettings(ctx context.Context, settings Notifica
5559
returnnil
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,methodstring)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
returnnil
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
iferr!=nil {

‎docs/api/general.md

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp