| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | package api | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/api/response" | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | 	contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model" | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ProvisioningApiHandler struct { | 
					
						
							|  |  |  | 	svc *ProvisioningSrv | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NewProvisioningApi(svc *ProvisioningSrv) *ProvisioningApiHandler { | 
					
						
							|  |  |  | 	return &ProvisioningApiHandler{ | 
					
						
							|  |  |  | 		svc: svc, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetPolicyTree(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetPolicyTree(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutPolicyTree(ctx *contextmodel.ReqContext, route apimodels.Route) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutPolicyTree(ctx, route) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetContactpoints(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetContactPoints(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePostContactpoints(ctx *contextmodel.ReqContext, cp apimodels.EmbeddedContactPoint) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePostContactPoint(ctx, cp) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutContactpoint(ctx *contextmodel.ReqContext, cp apimodels.EmbeddedContactPoint, UID string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutContactPoint(ctx, cp, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteDeleteContactpoints(ctx *contextmodel.ReqContext, UID string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteDeleteContactPoint(ctx, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetTemplates(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetTemplates(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetTemplate(ctx *contextmodel.ReqContext, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetTemplate(ctx, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutTemplate(ctx *contextmodel.ReqContext, body apimodels.NotificationTemplateContent, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutTemplate(ctx, body, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteDeleteTemplate(ctx *contextmodel.ReqContext, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteDeleteTemplate(ctx, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetMuteTiming(ctx *contextmodel.ReqContext, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetMuteTiming(ctx, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetMuteTimings(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetMuteTimings(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePostMuteTiming(ctx *contextmodel.ReqContext, mt apimodels.MuteTimeInterval) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePostMuteTiming(ctx, mt) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutMuteTiming(ctx *contextmodel.ReqContext, mt apimodels.MuteTimeInterval, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutMuteTiming(ctx, mt, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteDeleteMuteTiming(ctx *contextmodel.ReqContext, name string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteDeleteMuteTiming(ctx, name) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRules(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-12-13 18:54:08 +08:00
										 |  |  | 	return f.svc.RouteGetAlertRules(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRule(ctx *contextmodel.ReqContext, UID string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteRouteGetAlertRule(ctx, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 00:39:16 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRuleExport(ctx *contextmodel.ReqContext, UID string) response.Response { | 
					
						
							|  |  |  | 	return f.svc.RouteGetAlertRuleExport(ctx, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRulesExport(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							|  |  |  | 	return f.svc.RouteGetAlertRulesExport(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePostAlertRule(ctx *contextmodel.ReqContext, ar apimodels.ProvisionedAlertRule) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePostAlertRule(ctx, ar) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutAlertRule(ctx *contextmodel.ReqContext, ar apimodels.ProvisionedAlertRule, UID string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutAlertRule(ctx, ar, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteDeleteAlertRule(ctx *contextmodel.ReqContext, UID string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteDeleteAlertRule(ctx, UID) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteResetPolicyTree(ctx *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteResetPolicyTree(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRuleGroup(ctx *contextmodel.ReqContext, folder, group string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RouteGetAlertRuleGroup(ctx, folder, group) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 00:39:16 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRouteGetAlertRuleGroupExport(ctx *contextmodel.ReqContext, folder, group string) response.Response { | 
					
						
							|  |  |  | 	return f.svc.RouteGetAlertRuleGroupExport(ctx, folder, group) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ProvisioningApiHandler) handleRoutePutAlertRuleGroup(ctx *contextmodel.ReqContext, ag apimodels.AlertRuleGroup, folder, group string) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.svc.RoutePutAlertRuleGroup(ctx, ag, folder, group) | 
					
						
							|  |  |  | } |