Chore: Move swagger definitions to the handlers (#52643)

This commit is contained in:
Sofia Papagiannaki
2022-07-27 16:54:37 +03:00
committed by GitHub
parent c968b76279
commit 7ba076de10
76 changed files with 6022 additions and 6161 deletions

View File

@ -10,6 +10,19 @@ import (
"github.com/grafana/grafana/pkg/setting"
)
// swagger:route GET /admin/settings admin adminGetSettings
//
// Fetch settings.
//
// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `settings:read` and scopes: `settings:*`, `settings:auth.saml:` and `settings:auth.saml:enabled` (property level).
//
// Security:
// - basic:
//
// Responses:
// 200: adminGetSettingsResponse
// 401: unauthorisedError
// 403: forbiddenError
func (hs *HTTPServer) AdminGetSettings(c *models.ReqContext) response.Response {
settings, err := hs.getAuthorizedSettings(c.Req.Context(), c.SignedInUser, hs.SettingsProvider.Current())
if err != nil {
@ -18,6 +31,18 @@ func (hs *HTTPServer) AdminGetSettings(c *models.ReqContext) response.Response {
return response.JSON(http.StatusOK, settings)
}
// swagger:route GET /admin/stats admin adminGetStats
//
// Fetch Grafana Stats.
//
// Only works with Basic Authentication (username and password). See introduction for an explanation.
// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `server:stats:read`.
//
// Responses:
// 200: adminGetStatsResponse
// 401: unauthorisedError
// 403: forbiddenError
// 500: internalServerError
func (hs *HTTPServer) AdminGetStats(c *models.ReqContext) response.Response {
statsQuery := models.GetAdminStatsQuery{}
@ -72,3 +97,15 @@ func (hs *HTTPServer) getAuthorizedSettings(ctx context.Context, user *models.Si
}
return authorizedBag, nil
}
// swagger:response adminGetSettingsResponse
type GetSettingsResponse struct {
// in:body
Body setting.SettingsBag `json:"body"`
}
// swagger:response adminGetStatsResponse
type GetStatsResponse struct {
// in:body
Body models.AdminStats `json:"body"`
}