Chore: Move ReqContext to contexthandler service (#62102)
* Chore: Move ReqContext to contexthandler service * Rename package to contextmodel * Generate ngalert files * Remove unused imports
This commit is contained in:
@@ -12,39 +12,39 @@ import (
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
type AlertmanagerApi interface {
|
||||
RouteCreateGrafanaSilence(*models.ReqContext) response.Response
|
||||
RouteCreateSilence(*models.ReqContext) response.Response
|
||||
RouteDeleteAlertingConfig(*models.ReqContext) response.Response
|
||||
RouteDeleteGrafanaAlertingConfig(*models.ReqContext) response.Response
|
||||
RouteDeleteGrafanaSilence(*models.ReqContext) response.Response
|
||||
RouteDeleteSilence(*models.ReqContext) response.Response
|
||||
RouteGetAMAlertGroups(*models.ReqContext) response.Response
|
||||
RouteGetAMAlerts(*models.ReqContext) response.Response
|
||||
RouteGetAMStatus(*models.ReqContext) response.Response
|
||||
RouteGetAlertingConfig(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaAMAlertGroups(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaAMAlerts(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaAMStatus(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaAlertingConfig(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaReceivers(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaSilence(*models.ReqContext) response.Response
|
||||
RouteGetGrafanaSilences(*models.ReqContext) response.Response
|
||||
RouteGetSilence(*models.ReqContext) response.Response
|
||||
RouteGetSilences(*models.ReqContext) response.Response
|
||||
RoutePostAMAlerts(*models.ReqContext) response.Response
|
||||
RoutePostAlertingConfig(*models.ReqContext) response.Response
|
||||
RoutePostGrafanaAlertingConfig(*models.ReqContext) response.Response
|
||||
RoutePostTestGrafanaReceivers(*models.ReqContext) response.Response
|
||||
RouteCreateGrafanaSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteCreateSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteGrafanaSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteGetAMAlertGroups(*contextmodel.ReqContext) response.Response
|
||||
RouteGetAMAlerts(*contextmodel.ReqContext) response.Response
|
||||
RouteGetAMStatus(*contextmodel.ReqContext) response.Response
|
||||
RouteGetAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaAMAlertGroups(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaAMAlerts(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaAMStatus(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaReceivers(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteGetGrafanaSilences(*contextmodel.ReqContext) response.Response
|
||||
RouteGetSilence(*contextmodel.ReqContext) response.Response
|
||||
RouteGetSilences(*contextmodel.ReqContext) response.Response
|
||||
RoutePostAMAlerts(*contextmodel.ReqContext) response.Response
|
||||
RoutePostAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RoutePostGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RoutePostTestGrafanaReceivers(*contextmodel.ReqContext) response.Response
|
||||
}
|
||||
|
||||
func (f *AlertmanagerApiHandler) RouteCreateGrafanaSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteCreateGrafanaSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Request Body
|
||||
conf := apimodels.PostableSilence{}
|
||||
if err := web.Bind(ctx.Req, &conf); err != nil {
|
||||
@@ -52,7 +52,7 @@ func (f *AlertmanagerApiHandler) RouteCreateGrafanaSilence(ctx *models.ReqContex
|
||||
}
|
||||
return f.handleRouteCreateGrafanaSilence(ctx, conf)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteCreateSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteCreateSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
// Parse Request Body
|
||||
@@ -62,80 +62,80 @@ func (f *AlertmanagerApiHandler) RouteCreateSilence(ctx *models.ReqContext) resp
|
||||
}
|
||||
return f.handleRouteCreateSilence(ctx, conf, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteDeleteAlertingConfig(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteGrafanaAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteDeleteGrafanaAlertingConfig(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteGrafanaSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteGrafanaSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
silenceIdParam := web.Params(ctx.Req)[":SilenceId"]
|
||||
return f.handleRouteDeleteGrafanaSilence(ctx, silenceIdParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteDeleteSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
silenceIdParam := web.Params(ctx.Req)[":SilenceId"]
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteDeleteSilence(ctx, silenceIdParam, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMAlertGroups(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMAlertGroups(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetAMAlertGroups(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMAlerts(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMAlerts(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetAMAlerts(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMStatus(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetAMStatus(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetAMStatus(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetAlertingConfig(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlertGroups(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlertGroups(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaAMAlertGroups(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlerts(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlerts(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaAMAlerts(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMStatus(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAMStatus(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaAMStatus(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaAlertingConfig(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaReceivers(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaReceivers(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaReceivers(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
silenceIdParam := web.Params(ctx.Req)[":SilenceId"]
|
||||
return f.handleRouteGetGrafanaSilence(ctx, silenceIdParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaSilences(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetGrafanaSilences(ctx *contextmodel.ReqContext) response.Response {
|
||||
return f.handleRouteGetGrafanaSilences(ctx)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetSilence(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetSilence(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
silenceIdParam := web.Params(ctx.Req)[":SilenceId"]
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetSilence(ctx, silenceIdParam, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RouteGetSilences(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RouteGetSilences(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
return f.handleRouteGetSilences(ctx, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostAMAlerts(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RoutePostAMAlerts(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
// Parse Request Body
|
||||
@@ -145,7 +145,7 @@ func (f *AlertmanagerApiHandler) RoutePostAMAlerts(ctx *models.ReqContext) respo
|
||||
}
|
||||
return f.handleRoutePostAMAlerts(ctx, conf, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RoutePostAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
datasourceUIDParam := web.Params(ctx.Req)[":DatasourceUID"]
|
||||
// Parse Request Body
|
||||
@@ -155,7 +155,7 @@ func (f *AlertmanagerApiHandler) RoutePostAlertingConfig(ctx *models.ReqContext)
|
||||
}
|
||||
return f.handleRoutePostAlertingConfig(ctx, conf, datasourceUIDParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Request Body
|
||||
conf := apimodels.PostableUserConfig{}
|
||||
if err := web.Bind(ctx.Req, &conf); err != nil {
|
||||
@@ -163,7 +163,7 @@ func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig(ctx *models.ReqC
|
||||
}
|
||||
return f.handleRoutePostGrafanaAlertingConfig(ctx, conf)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostTestGrafanaReceivers(ctx *models.ReqContext) response.Response {
|
||||
func (f *AlertmanagerApiHandler) RoutePostTestGrafanaReceivers(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Request Body
|
||||
conf := apimodels.TestReceiversConfigBodyParams{}
|
||||
if err := web.Bind(ctx.Req, &conf); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user