| 1579 | } |
| 1580 | |
| 1581 | func (r *Ruler) DeleteTenantConfiguration(w http.ResponseWriter, req *http.Request) { |
| 1582 | logger := util_log.WithContext(req.Context(), r.logger) |
| 1583 | |
| 1584 | userID, err := users.TenantID(req.Context()) |
| 1585 | if err != nil { |
| 1586 | // When Cortex is running, it uses Auth Middleware for checking X-Scope-OrgID and injecting tenant into context. |
| 1587 | // Auth Middleware sends http.StatusUnauthorized if X-Scope-OrgID is missing, so we do too here, for consistency. |
| 1588 | http.Error(w, err.Error(), http.StatusUnauthorized) |
| 1589 | return |
| 1590 | } |
| 1591 | |
| 1592 | err = r.store.DeleteNamespace(req.Context(), userID, "") // Empty namespace = delete all rule groups. |
| 1593 | if err != nil && !errors.Is(err, rulestore.ErrGroupNamespaceNotFound) { |
| 1594 | util_api.RespondError(logger, w, v1.ErrServer, err.Error(), http.StatusInternalServerError) |
| 1595 | return |
| 1596 | } |
| 1597 | |
| 1598 | level.Info(logger).Log("msg", "deleted all tenant rule groups", "user", userID) |
| 1599 | w.WriteHeader(http.StatusOK) |
| 1600 | } |
| 1601 | |
| 1602 | func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request) { |
| 1603 | logger := util_log.WithContext(req.Context(), r.logger) |