| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | /*Package api contains base API implementation of unified alerting | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-09 17:55:41 +08:00
										 |  |  |  *Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-09 17:55:41 +08:00
										 |  |  |  *Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them. | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-12-13 16:22:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | package api | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 	"net/http" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/api/response" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/api/routing" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/models" | 
					
						
							| 
									
										
										
										
											2021-05-01 00:28:06 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/ngalert/metrics" | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 16:22:57 +08:00
										 |  |  | type PrometheusApiForkingService interface { | 
					
						
							|  |  |  | 	RouteGetAlertStatuses(*models.ReqContext) response.Response | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | 	RouteGetGrafanaAlertStatuses(*models.ReqContext) response.Response | 
					
						
							|  |  |  | 	RouteGetGrafanaRuleStatuses(*models.ReqContext) response.Response | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | 	RouteGetRuleStatuses(*models.ReqContext) response.Response | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 16:22:57 +08:00
										 |  |  | func (f *ForkedPrometheusApi) RouteGetAlertStatuses(ctx *models.ReqContext) response.Response { | 
					
						
							|  |  |  | 	return f.forkRouteGetAlertStatuses(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | func (f *ForkedPrometheusApi) RouteGetGrafanaAlertStatuses(ctx *models.ReqContext) response.Response { | 
					
						
							|  |  |  | 	return f.forkRouteGetGrafanaAlertStatuses(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (f *ForkedPrometheusApi) RouteGetGrafanaRuleStatuses(ctx *models.ReqContext) response.Response { | 
					
						
							|  |  |  | 	return f.forkRouteGetGrafanaRuleStatuses(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 16:22:57 +08:00
										 |  |  | func (f *ForkedPrometheusApi) RouteGetRuleStatuses(ctx *models.ReqContext) response.Response { | 
					
						
							|  |  |  | 	return f.forkRouteGetRuleStatuses(ctx) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiForkingService, m *metrics.API) { | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | 	api.RouteRegister.Group("", func(group routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 		group.Get( | 
					
						
							|  |  |  | 			toMacaronPath("/api/prometheus/{Recipient}/api/v1/alerts"), | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | 			api.authorize(http.MethodGet, "/api/prometheus/{Recipient}/api/v1/alerts"), | 
					
						
							| 
									
										
										
										
											2021-05-01 00:28:06 +08:00
										 |  |  | 			metrics.Instrument( | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 				http.MethodGet, | 
					
						
							|  |  |  | 				"/api/prometheus/{Recipient}/api/v1/alerts", | 
					
						
							|  |  |  | 				srv.RouteGetAlertStatuses, | 
					
						
							| 
									
										
										
										
											2021-05-01 00:28:06 +08:00
										 |  |  | 				m, | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 			), | 
					
						
							|  |  |  | 		) | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | 		group.Get( | 
					
						
							|  |  |  | 			toMacaronPath("/api/prometheus/grafana/api/v1/alerts"), | 
					
						
							|  |  |  | 			api.authorize(http.MethodGet, "/api/prometheus/grafana/api/v1/alerts"), | 
					
						
							|  |  |  | 			metrics.Instrument( | 
					
						
							|  |  |  | 				http.MethodGet, | 
					
						
							|  |  |  | 				"/api/prometheus/grafana/api/v1/alerts", | 
					
						
							|  |  |  | 				srv.RouteGetGrafanaAlertStatuses, | 
					
						
							|  |  |  | 				m, | 
					
						
							|  |  |  | 			), | 
					
						
							|  |  |  | 		) | 
					
						
							|  |  |  | 		group.Get( | 
					
						
							|  |  |  | 			toMacaronPath("/api/prometheus/grafana/api/v1/rules"), | 
					
						
							|  |  |  | 			api.authorize(http.MethodGet, "/api/prometheus/grafana/api/v1/rules"), | 
					
						
							|  |  |  | 			metrics.Instrument( | 
					
						
							|  |  |  | 				http.MethodGet, | 
					
						
							|  |  |  | 				"/api/prometheus/grafana/api/v1/rules", | 
					
						
							|  |  |  | 				srv.RouteGetGrafanaRuleStatuses, | 
					
						
							|  |  |  | 				m, | 
					
						
							|  |  |  | 			), | 
					
						
							|  |  |  | 		) | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 		group.Get( | 
					
						
							|  |  |  | 			toMacaronPath("/api/prometheus/{Recipient}/api/v1/rules"), | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | 			api.authorize(http.MethodGet, "/api/prometheus/{Recipient}/api/v1/rules"), | 
					
						
							| 
									
										
										
										
											2021-05-01 00:28:06 +08:00
										 |  |  | 			metrics.Instrument( | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 				http.MethodGet, | 
					
						
							|  |  |  | 				"/api/prometheus/{Recipient}/api/v1/rules", | 
					
						
							|  |  |  | 				srv.RouteGetRuleStatuses, | 
					
						
							| 
									
										
										
										
											2021-05-01 00:28:06 +08:00
										 |  |  | 				m, | 
					
						
							| 
									
										
										
										
											2021-04-29 04:59:15 +08:00
										 |  |  | 			), | 
					
						
							|  |  |  | 		) | 
					
						
							| 
									
										
										
										
											2022-02-05 01:42:04 +08:00
										 |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2021-03-12 03:28:00 +08:00
										 |  |  | } |