MCPcopy Index your code
hub / github.com/cortexproject/cortex / DeleteUserConfig

Method DeleteUserConfig

pkg/alertmanager/api.go:184–201  ·  view source on GitHub ↗

DeleteUserConfig is exposed via user-visible API (if enabled, uses DELETE method), but also as an internal endpoint using POST method. Note that if no config exists for a user, StatusOK is returned.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

182// DeleteUserConfig is exposed via user-visible API (if enabled, uses DELETE method), but also as an internal endpoint using POST method.
183// Note that if no config exists for a user, StatusOK is returned.
184func (am *MultitenantAlertmanager) DeleteUserConfig(w http.ResponseWriter, r *http.Request) {
185 logger := util_log.WithContext(r.Context(), am.logger)
186 userID, err := users.TenantID(r.Context())
187 if err != nil {
188 level.Error(logger).Log("msg", errNoOrgID, "err", err.Error())
189 http.Error(w, fmt.Sprintf("%s: %s", errNoOrgID, err.Error()), http.StatusUnauthorized)
190 return
191 }
192
193 err = am.store.DeleteAlertConfig(r.Context(), userID)
194 if err != nil {
195 level.Error(logger).Log("msg", errDeletingConfiguration, "err", err.Error())
196 http.Error(w, fmt.Sprintf("%s: %s", errDeletingConfiguration, err.Error()), http.StatusInternalServerError)
197 return
198 }
199
200 w.WriteHeader(http.StatusOK)
201}
202
203// Partially copied from: https://github.com/prometheus/alertmanager/blob/8e861c646bf67599a1704fc843c6a94d519ce312/cli/check_config.go#L65-L96
204func validateUserConfig(logger log.Logger, cfg alertspb.AlertConfigDesc, limits Limits, user string) error {

Calls 5

TenantIDFunction · 0.92
DeleteAlertConfigMethod · 0.65
ContextMethod · 0.45
LogMethod · 0.45
ErrorMethod · 0.45