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

Commit49c1c14

Browse files
committed
Use PUT since this endpoint is idempotent
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent9406953 commit49c1c14

File tree

9 files changed

+9
-64
lines changed

9 files changed

+9
-64
lines changed

‎coderd/apidoc/docs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ func New(options *Options) *API {
12501250
r.Get("/settings",api.notificationsSettings)
12511251
r.Put("/settings",api.putNotificationsSettings)
12521252
r.Route("/templates",func(r chi.Router) {
1253-
r.Get("/system",api.getSystemNotificationTemplates)
1253+
r.Get("/system",api.systemNotificationTemplates)
12541254
})
12551255
})
12561256
})

‎coderd/notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (api *API) putNotificationsSettings(rw http.ResponseWriter, r *http.Request
128128
// @Tags Notifications
129129
// @Success 200 {array} codersdk.NotificationTemplate
130130
// @Router /notifications/templates/system [get]
131-
func (api*API)getSystemNotificationTemplates(rw http.ResponseWriter,r*http.Request) {
131+
func (api*API)systemNotificationTemplates(rw http.ResponseWriter,r*http.Request) {
132132
ctx:=r.Context()
133133

134134
templates,err:=api.Database.GetNotificationTemplatesByKind(ctx,database.NotificationTemplateKindSystem)

‎codersdk/notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (c *Client) PutNotificationsSettings(ctx context.Context, settings Notifica
6262
// UpdateNotificationTemplateMethod modifies a notification template to use a specific notification method, overriding
6363
// the method set in the deployment configuration.
6464
func (c*Client)UpdateNotificationTemplateMethod(ctx context.Context,notificationTemplateId uuid.UUID,methodstring)error {
65-
res,err:=c.Request(ctx,http.MethodPost,
65+
res,err:=c.Request(ctx,http.MethodPut,
6666
fmt.Sprintf("/api/v2/notifications/templates/%s/method",notificationTemplateId),
6767
UpdateNotificationTemplateMethod{Method:method},
6868
)

‎docs/api/enterprise.md

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

‎enterprise/coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
395395
apiKeyMiddleware,
396396
httpmw.RequireExperiment(api.AGPL.Experiments,codersdk.ExperimentNotifications),
397397
httpmw.ExtractNotificationTemplateParam(options.Database),
398-
).Post("/notifications/templates/{notification_template}/method",api.updateNotificationTemplateMethod)
398+
).Put("/notifications/templates/{notification_template}/method",api.updateNotificationTemplateMethod)
399399
})
400400

401401
iflen(options.SCIMAPIKey)!=0 {

‎enterprise/coderd/notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
// @Produce json
2121
// @Tags Enterprise
2222
// @Success 200
23-
// @Router /notifications/templates/{notification_template}/method [post]
23+
// @Router /notifications/templates/{notification_template}/method [put]
2424
func (api*API)updateNotificationTemplateMethod(rw http.ResponseWriter,r*http.Request) {
2525
// TODO: authorization (restrict to admin/template admin?)
2626
var (

‎enterprise/coderd/notifications_test.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -148,61 +148,6 @@ func TestUpdateNotificationTemplateMethod(t *testing.T) {
148148
require.NotNil(t,template)
149149
require.Equal(t,method,template.Method)
150150
})
151-
152-
// t.Run("Settings modified", func(t *testing.T) {
153-
// t.Parallel()
154-
//
155-
// client := coderdtest.New(t, nil)
156-
// _ = coderdtest.CreateFirstUser(t, client)
157-
//
158-
// // given
159-
// expected := codersdk.NotificationsSettings{
160-
// NotifierPaused: true,
161-
// }
162-
//
163-
// ctx := testutil.Context(t, testutil.WaitShort)
164-
//
165-
// // when
166-
// err := client.PutNotificationsSettings(ctx, expected)
167-
// require.NoError(t, err)
168-
//
169-
// // then
170-
// actual, err := client.GetNotificationsSettings(ctx)
171-
// require.NoError(t, err)
172-
// require.Equal(t, expected, actual)
173-
// })
174-
//
175-
// t.Run("Settings not modified", func(t *testing.T) {
176-
// t.Parallel()
177-
//
178-
// // Empty state: notifications Settings are undefined now (default).
179-
// client := coderdtest.New(t, nil)
180-
// _ = coderdtest.CreateFirstUser(t, client)
181-
// ctx := testutil.Context(t, testutil.WaitShort)
182-
//
183-
// // Change the state: pause notifications
184-
// err := client.PutNotificationsSettings(ctx, codersdk.NotificationsSettings{
185-
// NotifierPaused: true,
186-
// })
187-
// require.NoError(t, err)
188-
//
189-
// // Verify the state: notifications are paused.
190-
// actual, err := client.GetNotificationsSettings(ctx)
191-
// require.NoError(t, err)
192-
// require.True(t, actual.NotifierPaused)
193-
//
194-
// // Change the stage again: notifications are paused.
195-
// expected := actual
196-
// err = client.PutNotificationsSettings(ctx, codersdk.NotificationsSettings{
197-
// NotifierPaused: true,
198-
// })
199-
// require.NoError(t, err)
200-
//
201-
// // Verify the state: notifications are still paused, and there is no error returned.
202-
// actual, err = client.GetNotificationsSettings(ctx)
203-
// require.NoError(t, err)
204-
// require.Equal(t, expected.NotifierPaused, actual.NotifierPaused)
205-
// })
206151
}
207152

208153
funcgetTemplateById(t*testing.T,ctx context.Context,api*codersdk.Client,id uuid.UUID) (*codersdk.NotificationTemplate,error) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp