MCPcopy Index your code
hub / github.com/coder/coder / GetNotificationDispatchMethods

Method GetNotificationDispatchMethods

codersdk/notifications.go:173–195  ·  view source on GitHub ↗

GetNotificationDispatchMethods the available and default notification dispatch methods.

(ctx context.Context)

Source from the content-addressed store, hash-verified

171
172// GetNotificationDispatchMethods the available and default notification dispatch methods.
173func (c *Client) GetNotificationDispatchMethods(ctx context.Context) (NotificationMethodsResponse, error) {
174 res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/dispatch-methods", nil)
175 if err != nil {
176 return NotificationMethodsResponse{}, err
177 }
178 defer res.Body.Close()
179
180 if res.StatusCode != http.StatusOK {
181 return NotificationMethodsResponse{}, ReadBodyAsError(res)
182 }
183
184 var resp NotificationMethodsResponse
185 body, err := io.ReadAll(res.Body)
186 if err != nil {
187 return NotificationMethodsResponse{}, xerrors.Errorf("read response body: %w", err)
188 }
189
190 if err := json.Unmarshal(body, &resp); err != nil {
191 return NotificationMethodsResponse{}, xerrors.Errorf("unmarshal response body: %w", err)
192 }
193
194 return resp, nil
195}
196
197func (c *Client) PostTestNotification(ctx context.Context) error {
198 res, err := c.Request(ctx, http.MethodPost, "/api/v2/notifications/test", nil)

Callers 1

Calls 6

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
ReadAllMethod · 0.45
ErrorfMethod · 0.45
UnmarshalMethod · 0.45

Tested by 1