2021-08-06 07:06:56 -05:00
|
|
|
/*Package api contains base API implementation of unified alerting
|
|
|
|
*
|
|
|
|
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
|
|
*
|
|
|
|
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
|
|
|
|
*/
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
2022-03-24 16:13:47 -05:00
|
|
|
"github.com/grafana/grafana/pkg/middleware"
|
2023-08-29 05:43:33 -05:00
|
|
|
"github.com/grafana/grafana/pkg/middleware/requestmeta"
|
2023-01-27 01:50:36 -06:00
|
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
2021-08-06 07:06:56 -05:00
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
2021-12-13 02:22:57 -06:00
|
|
|
"github.com/grafana/grafana/pkg/web"
|
2021-08-06 07:06:56 -05:00
|
|
|
)
|
|
|
|
|
2022-07-18 02:08:08 -05:00
|
|
|
type ConfigurationApi interface {
|
2023-01-27 01:50:36 -06:00
|
|
|
RouteDeleteNGalertConfig(*contextmodel.ReqContext) response.Response
|
|
|
|
RouteGetAlertmanagers(*contextmodel.ReqContext) response.Response
|
|
|
|
RouteGetNGalertConfig(*contextmodel.ReqContext) response.Response
|
|
|
|
RouteGetStatus(*contextmodel.ReqContext) response.Response
|
|
|
|
RoutePostNGalertConfig(*contextmodel.ReqContext) response.Response
|
2021-12-13 02:22:57 -06:00
|
|
|
}
|
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *ConfigurationApiHandler) RouteDeleteNGalertConfig(ctx *contextmodel.ReqContext) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.handleRouteDeleteNGalertConfig(ctx)
|
2021-12-13 02:22:57 -06:00
|
|
|
}
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *ConfigurationApiHandler) RouteGetAlertmanagers(ctx *contextmodel.ReqContext) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.handleRouteGetAlertmanagers(ctx)
|
2021-12-13 02:22:57 -06:00
|
|
|
}
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *ConfigurationApiHandler) RouteGetNGalertConfig(ctx *contextmodel.ReqContext) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.handleRouteGetNGalertConfig(ctx)
|
2021-12-13 02:22:57 -06:00
|
|
|
}
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *ConfigurationApiHandler) RouteGetStatus(ctx *contextmodel.ReqContext) response.Response {
|
2022-09-14 13:03:10 -05:00
|
|
|
return f.handleRouteGetStatus(ctx)
|
|
|
|
}
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *ConfigurationApiHandler) RoutePostNGalertConfig(ctx *contextmodel.ReqContext) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
// Parse Request Body
|
2021-12-13 02:22:57 -06:00
|
|
|
conf := apimodels.PostableNGalertConfig{}
|
|
|
|
if err := web.Bind(ctx.Req, &conf); err != nil {
|
|
|
|
return response.Error(http.StatusBadRequest, "bad request data", err)
|
|
|
|
}
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.handleRoutePostNGalertConfig(ctx, conf)
|
2021-12-13 02:22:57 -06:00
|
|
|
}
|
|
|
|
|
2022-07-18 02:08:08 -05:00
|
|
|
func (api *API) RegisterConfigurationApiEndpoints(srv ConfigurationApi, m *metrics.API) {
|
2021-08-06 07:06:56 -05:00
|
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
|
|
|
group.Delete(
|
|
|
|
toMacaronPath("/api/v1/ngalert/admin_config"),
|
2023-08-29 05:43:33 -05:00
|
|
|
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
2023-09-29 07:56:48 -05:00
|
|
|
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
2022-02-04 11:42:04 -06:00
|
|
|
api.authorize(http.MethodDelete, "/api/v1/ngalert/admin_config"),
|
2021-08-06 07:06:56 -05:00
|
|
|
metrics.Instrument(
|
|
|
|
http.MethodDelete,
|
|
|
|
"/api/v1/ngalert/admin_config",
|
2023-04-24 11:18:44 -05:00
|
|
|
api.Hooks.Wrap(srv.RouteDeleteNGalertConfig),
|
2021-08-06 07:06:56 -05:00
|
|
|
m,
|
|
|
|
),
|
|
|
|
)
|
2021-08-13 07:14:36 -05:00
|
|
|
group.Get(
|
|
|
|
toMacaronPath("/api/v1/ngalert/alertmanagers"),
|
2023-08-29 05:43:33 -05:00
|
|
|
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
2023-09-29 07:56:48 -05:00
|
|
|
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
2022-02-04 11:42:04 -06:00
|
|
|
api.authorize(http.MethodGet, "/api/v1/ngalert/alertmanagers"),
|
2021-08-13 07:14:36 -05:00
|
|
|
metrics.Instrument(
|
|
|
|
http.MethodGet,
|
|
|
|
"/api/v1/ngalert/alertmanagers",
|
2023-04-24 11:18:44 -05:00
|
|
|
api.Hooks.Wrap(srv.RouteGetAlertmanagers),
|
2021-08-13 07:14:36 -05:00
|
|
|
m,
|
|
|
|
),
|
|
|
|
)
|
2021-08-06 07:06:56 -05:00
|
|
|
group.Get(
|
|
|
|
toMacaronPath("/api/v1/ngalert/admin_config"),
|
2023-08-29 05:43:33 -05:00
|
|
|
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
2023-09-29 07:56:48 -05:00
|
|
|
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
2022-02-04 11:42:04 -06:00
|
|
|
api.authorize(http.MethodGet, "/api/v1/ngalert/admin_config"),
|
2021-08-06 07:06:56 -05:00
|
|
|
metrics.Instrument(
|
|
|
|
http.MethodGet,
|
|
|
|
"/api/v1/ngalert/admin_config",
|
2023-04-24 11:18:44 -05:00
|
|
|
api.Hooks.Wrap(srv.RouteGetNGalertConfig),
|
2021-08-06 07:06:56 -05:00
|
|
|
m,
|
|
|
|
),
|
|
|
|
)
|
2022-09-14 13:03:10 -05:00
|
|
|
group.Get(
|
|
|
|
toMacaronPath("/api/v1/ngalert"),
|
2023-08-29 05:43:33 -05:00
|
|
|
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
2023-09-29 07:56:48 -05:00
|
|
|
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
2022-09-14 13:03:10 -05:00
|
|
|
api.authorize(http.MethodGet, "/api/v1/ngalert"),
|
|
|
|
metrics.Instrument(
|
|
|
|
http.MethodGet,
|
|
|
|
"/api/v1/ngalert",
|
2023-04-24 11:18:44 -05:00
|
|
|
api.Hooks.Wrap(srv.RouteGetStatus),
|
2022-09-14 13:03:10 -05:00
|
|
|
m,
|
|
|
|
),
|
|
|
|
)
|
2021-08-06 07:06:56 -05:00
|
|
|
group.Post(
|
|
|
|
toMacaronPath("/api/v1/ngalert/admin_config"),
|
2023-08-29 05:43:33 -05:00
|
|
|
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
2023-09-29 07:56:48 -05:00
|
|
|
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
2022-02-04 11:42:04 -06:00
|
|
|
api.authorize(http.MethodPost, "/api/v1/ngalert/admin_config"),
|
2021-08-06 07:06:56 -05:00
|
|
|
metrics.Instrument(
|
|
|
|
http.MethodPost,
|
|
|
|
"/api/v1/ngalert/admin_config",
|
2023-04-24 11:18:44 -05:00
|
|
|
api.Hooks.Wrap(srv.RoutePostNGalertConfig),
|
2021-08-06 07:06:56 -05:00
|
|
|
m,
|
|
|
|
),
|
|
|
|
)
|
2022-03-24 16:13:47 -05:00
|
|
|
}, middleware.ReqSignedIn)
|
2021-08-06 07:06:56 -05:00
|
|
|
}
|