| 
									
										
										
										
											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" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ConfigurationApiHandler always forwards requests to grafana backend
 | 
					
						
							|  |  |  | type ConfigurationApiHandler struct { | 
					
						
							|  |  |  | 	grafana *ConfigSrv | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NewConfiguration(grafana *ConfigSrv) *ConfigurationApiHandler { | 
					
						
							|  |  |  | 	return &ConfigurationApiHandler{ | 
					
						
							|  |  |  | 		grafana: grafana, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ConfigurationApiHandler) handleRouteGetAlertmanagers(c *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.grafana.RouteGetAlertmanagers(c) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ConfigurationApiHandler) handleRouteGetNGalertConfig(c *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.grafana.RouteGetNGalertConfig(c) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ConfigurationApiHandler) handleRoutePostNGalertConfig(c *contextmodel.ReqContext, body apimodels.PostableNGalertConfig) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.grafana.RoutePostNGalertConfig(c, body) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ConfigurationApiHandler) handleRouteDeleteNGalertConfig(c *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:08:08 +08:00
										 |  |  | 	return f.grafana.RouteDeleteNGalertConfig(c) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-15 02:03:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 15:50:36 +08:00
										 |  |  | func (f *ConfigurationApiHandler) handleRouteGetStatus(c *contextmodel.ReqContext) response.Response { | 
					
						
							| 
									
										
										
										
											2022-09-15 02:03:10 +08:00
										 |  |  | 	return f.grafana.RouteGetAlertingStatus(c) | 
					
						
							|  |  |  | } |