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

Method GetSystemNotificationTemplates

codersdk/notifications.go:98–120  ·  view source on GitHub ↗

GetSystemNotificationTemplates retrieves all notification templates pertaining to internal system events.

(ctx context.Context)

Source from the content-addressed store, hash-verified

96
97// GetSystemNotificationTemplates retrieves all notification templates pertaining to internal system events.
98func (c *Client) GetSystemNotificationTemplates(ctx context.Context) ([]NotificationTemplate, error) {
99 res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/templates/system", nil)
100 if err != nil {
101 return nil, err
102 }
103 defer res.Body.Close()
104
105 if res.StatusCode != http.StatusOK {
106 return nil, ReadBodyAsError(res)
107 }
108
109 var templates []NotificationTemplate
110 body, err := io.ReadAll(res.Body)
111 if err != nil {
112 return nil, xerrors.Errorf("read response body: %w", err)
113 }
114
115 if err := json.Unmarshal(body, &templates); err != nil {
116 return nil, xerrors.Errorf("unmarshal response body: %w", err)
117 }
118
119 return templates, nil
120}
121
122// GetUserNotificationPreferences retrieves notification preferences for a given user.
123func (c *Client) GetUserNotificationPreferences(ctx context.Context, userID uuid.UUID) ([]NotificationPreference, error) {

Callers 2

getTemplateByIDFunction · 0.80

Calls 6

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

Tested by 2

getTemplateByIDFunction · 0.64