Alerting: Provisioning API - Notification Policies (#46755)

* Base-line API for provisioning notification policies

* Wire API up, some simple tests

* Return provenance status through API

* Fix missing call

* Transactions

* Clarity in package dependencies

* Unify receivers in definitions

* Fix issue introduced by receiver change

* Drop unused internal test implementation

* FGAC hooks for provisioning routes

* Polish, swap names

* Asserting on number of exposed routes

* Don't bubble up updated object

* Integrate with new concurrency token feature in store

* Back out duplicated changes

* Remove redundant tests

* Regenerate and create unit tests for API layer

* Integration tests for auth

* Address linter errors

* Put route behind toggle

* Use alternative store API and fix feature toggle in tests

* Fixes, polish

* Fix whitespace

* Re-kick drone

* Rename services to provisioning
This commit is contained in:
Alexander Weaver
2022-04-05 16:48:51 -05:00
committed by GitHub
parent cb6124c921
commit dde0b93cf1
29 changed files with 1055 additions and 78 deletions
+11 -1
View File
@@ -11,11 +11,13 @@ import (
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/datasourceproxy"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/eval"
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/notifier"
"github.com/grafana/grafana/pkg/services/ngalert/provisioning"
"github.com/grafana/grafana/pkg/services/ngalert/schedule"
"github.com/grafana/grafana/pkg/services/ngalert/state"
"github.com/grafana/grafana/pkg/services/ngalert/store"
@@ -64,7 +66,7 @@ type API struct {
ExpressionService *expr.Service
QuotaService *quota.QuotaService
Schedule schedule.ScheduleService
TransactionManager store.TransactionManager
TransactionManager provisioning.TransactionManager
RuleStore store.RuleStore
InstanceStore store.InstanceStore
AlertingStore AlertingStore
@@ -74,6 +76,7 @@ type API struct {
StateManager *state.Manager
SecretsService secrets.Service
AccessControl accesscontrol.AccessControl
Policies *provisioning.NotificationPolicyService
}
// RegisterAPIEndpoints registers API handlers
@@ -126,4 +129,11 @@ func (api *API) RegisterAPIEndpoints(m *metrics.API) {
scheduler: api.Schedule,
},
), m)
if api.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagAlertProvisioning) {
api.RegisterProvisioningApiEndpoints(NewForkedProvisioningApi(&ProvisioningSrv{
log: logger,
policies: api.Policies,
}), m)
}
}