@Summary Get health settings @ID get-health-settings @Security CoderSessionToken @Produce json @Tags Debug @Success 200 {object} healthsdk.HealthSettings @Router /api/v2/debug/health/settings [get]
(rw http.ResponseWriter, r *http.Request)
| 170 | // @Success 200 {object} healthsdk.HealthSettings |
| 171 | // @Router /api/v2/debug/health/settings [get] |
| 172 | func (api *API) deploymentHealthSettings(rw http.ResponseWriter, r *http.Request) { |
| 173 | settingsJSON, err := api.Database.GetHealthSettings(r.Context()) |
| 174 | if err != nil { |
| 175 | httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{ |
| 176 | Message: "Failed to fetch health settings.", |
| 177 | Detail: err.Error(), |
| 178 | }) |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | var settings healthsdk.HealthSettings |
| 183 | err = json.Unmarshal([]byte(settingsJSON), &settings) |
| 184 | if err != nil { |
| 185 | httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{ |
| 186 | Message: "Failed to unmarshal health settings.", |
| 187 | Detail: err.Error(), |
| 188 | }) |
| 189 | return |
| 190 | } |
| 191 | |
| 192 | if len(settings.DismissedHealthchecks) == 0 { |
| 193 | settings.DismissedHealthchecks = []healthsdk.HealthSection{} |
| 194 | } |
| 195 | |
| 196 | httpapi.Write(r.Context(), rw, http.StatusOK, settings) |
| 197 | } |
| 198 | |
| 199 | // @Summary Update health settings |
| 200 | // @ID update-health-settings |
nothing calls this directly
no test coverage detected