2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Package api Grafana HTTP API.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// The Grafana backend exposes an HTTP API, the same API is used by the frontend to do
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// everything from saving dashboards, creating users and updating data sources.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-09-12 15:40:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	Schemes: http, https
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	BasePath: /api
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	Version: 0.0.1
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	Contact: Grafana Labs<hello@grafana.com> https://grafana.com
  
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-09-12 15:40:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	Consumes:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	- application/json
  
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-09-12 15:40:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	Produces:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	- application/json
  
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-09-12 15:40:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	Security:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	- basic:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	- api_key:
  
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-09-12 15:40:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	SecurityDefinitions:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	basic:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	 type: basic
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	api_key:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	 type: apiKey
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	 name: Authorization
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	 in: header
  
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:meta
  
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  api  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/api/routing" 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 16:32:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/infra/log" 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-05 17:37:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/middleware" 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/middleware/requestmeta" 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-24 17:36:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ac  "github.com/grafana/grafana/pkg/services/accesscontrol" 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/apikey" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/auth" 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-26 18:27:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/correlations" 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 00:57:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/dashboards" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/datasources" 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 01:44:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/featuremgmt" 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/org" 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 17:15:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol" 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-07 07:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									publicdashboardsapi  "github.com/grafana/grafana/pkg/services/publicdashboards/api" 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 19:40:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/serviceaccounts" 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/user" 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-12 15:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/setting" 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-07 00:24:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/web" 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 16:32:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  plog  =  log . New ( "api" )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-28 16:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// registerRoutes registers all API HTTP routes.
  
						 
					
						
							
								
									
										
										
										
											2018-03-23 05:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  registerRoutes ( )  {  
						 
					
						
							
								
									
										
										
										
											2021-03-16 23:46:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqNoAuth  :=  middleware . NoAuth ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-11 18:36:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqSignedIn  :=  middleware . ReqSignedIn 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 00:02:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqNotSignedIn  :=  middleware . ReqNotSignedIn 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 01:04:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqSignedInNoAnonymous  :=  middleware . ReqSignedInNoAnonymous 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-11 18:36:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqGrafanaAdmin  :=  middleware . ReqGrafanaAdmin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									reqEditorRole  :=  middleware . ReqEditorRole 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									reqOrgAdmin  :=  middleware . ReqOrgAdmin 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 23:12:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqRoleForAppRoute  :=  middleware . RoleAppPluginAuth ( hs . AccessControl ,  hs . pluginStore ,  hs . Features ,  hs . log ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-11 18:44:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									reqSnapshotPublicModeOrSignedIn  :=  middleware . SnapshotPublicModeOrSignedIn ( hs . Cfg ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-16 02:09:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									redirectFromLegacyPanelEditURL  :=  middleware . RedirectFromLegacyPanelEditURL ( hs . Cfg ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 16:46:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									authorize  :=  ac . Middleware ( hs . AccessControl ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-22 21:20:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									authorizeInOrg  :=  ac . AuthorizeInOrgMiddleware ( hs . AccessControl ,  hs . accesscontrolService ,  hs . userService ,  hs . teamService ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-12 04:12:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									quota  :=  middleware . Quota ( hs . QuotaService ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-27 19:41:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r  :=  hs . RouteRegister 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-29 20:45:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// not logged in views
 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-15 22:15:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/logout" ,  hs . Logout ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/login" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  quota ( string ( auth . QuotaTargetSrv ) ) ,  routing . Wrap ( hs . LoginPost ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/login/:name" ,  quota ( string ( auth . QuotaTargetSrv ) ) ,  hs . OAuthLogin ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/login" ,  hs . LoginView ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/invite/:code" ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// authed views
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-11 06:36:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 01:04:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/profile/" ,  reqSignedInNoAnonymous ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/profile/password" ,  reqSignedInNoAnonymous ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-11 06:36:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/.well-known/change-password" ,  redirectToChangePassword ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 01:04:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/profile/switch-org/:id" ,  reqSignedInNoAnonymous ,  hs . ChangeActiveOrgAndRedirectToHome ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/org/" ,  authorize ( ac . OrgPreferencesAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/new" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . OrgsCreateAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/datasources/" ,  authorize ( datasources . ConfigurationPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/datasources/new" ,  authorize ( datasources . NewPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/datasources/edit/*" ,  authorize ( datasources . EditPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/datasources/correlations" ,  authorize ( correlations . ConfigurationPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/users" ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-04 22:51:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/org/users/new" ,  reqOrgAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/org/users/invite" ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-20 20:51:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/org/teams" ,  authorize ( ac . TeamsAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/org/teams/edit/*" ,  authorize ( ac . TeamsEditAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/teams/new" ,  authorize ( ac . EvalPermission ( ac . ActionTeamsCreate ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/serviceaccounts" ,  authorize ( ac . EvalPermission ( serviceaccounts . ActionRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/serviceaccounts/:serviceAccountId" ,  authorize ( ac . EvalPermission ( serviceaccounts . ActionRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/org/apikeys/" ,  authorize ( ac . EvalPermission ( ac . ActionAPIKeyRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard/import/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/configuration" ,  reqGrafanaAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 22:35:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/admin" ,  reqOrgAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/admin/settings" ,  authorize ( ac . EvalPermission ( ac . ActionSettingsRead ,  ac . ScopeSettingsAll ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/users" ,  authorize ( ac . EvalAny ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ,  ac . EvalPermission ( ac . ActionUsersRead ,  ac . ScopeGlobalUsersAll ) ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/users/create" ,  authorize ( ac . EvalPermission ( ac . ActionUsersCreate ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/users/edit/:id" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/orgs" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . OrgsAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/orgs/edit/:id" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . OrgsAccessEvaluator ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/admin/stats" ,  authorize ( ac . EvalPermission ( ac . ActionServerStatsRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-13 00:15:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/admin/authentication/ldap" ,  authorize ( ac . EvalPermission ( ac . ActionLDAPStatusRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagStorage )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-09 02:57:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r . Get ( "/admin/storage" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r . Get ( "/admin/storage/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 02:17:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// feature toggle admin page
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagFeatureToggleAdminPage )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 02:17:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r . Get ( "/admin/featuretoggles" ,  authorize ( ac . EvalPermission ( ac . ActionFeatureManagementRead ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/styleguide" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 12:09:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/live" ,  reqGrafanaAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/live/pipeline" ,  reqGrafanaAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/live/cloud" ,  reqGrafanaAdmin ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 16:46:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/plugins" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/plugins/:id/" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/plugins/:id/edit" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index )  // deprecated
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/plugins/:id/page/:page" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-06 16:11:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/connections/datasources" ,  authorize ( datasources . ConfigurationPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections/datasources/new" ,  authorize ( datasources . NewPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections/datasources/edit/*" ,  authorize ( datasources . EditPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections" ,  authorize ( datasources . ConfigurationPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections/add-new-connection" ,  authorize ( datasources . ConfigurationPageAccess ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 16:46:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Plugin details pages
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections/datasources/:id" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/connections/datasources/:id/page/:page" ,  middleware . CanAdminPlugins ( hs . Cfg ,  hs . AccessControl ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-06 16:11:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 19:24:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// App Root Page
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 17:15:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									appPluginIDScope  :=  pluginaccesscontrol . ScopeProvider . GetResourceScope ( ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 23:12:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/a/:id/*" ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  appPluginIDScope ) ) ,  reqSignedIn ,  reqRoleForAppRoute ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/a/:id" ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  appPluginIDScope ) ) ,  reqSignedIn ,  reqRoleForAppRoute ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-17 18:51:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/d/:uid/:slug" ,  reqSignedIn ,  redirectFromLegacyPanelEditURL ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/d/:uid" ,  reqSignedIn ,  redirectFromLegacyPanelEditURL ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard/script/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-11 06:36:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard/new" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard-solo/snapshot/*" ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/d-solo/:uid/:slug" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 00:21:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/d-solo/:uid" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard-solo/script/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/import/dashboard" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/dashboards/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/dashboards/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 18:48:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/goto/:uid" ,  reqSignedIn ,  hs . redirectFromShortURL ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagDashboardEmbed )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 22:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r . Get ( "/d-embed" ,  reqSignedIn ,  middleware . AddAllowEmbeddingHeader ( ) ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 18:43:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagPublicDashboards )  &&  hs . Cfg . PublicDashboardsEnabled  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-13 13:36:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// list public dashboards
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r . Get ( "/public-dashboards/list" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// anonymous view public dashboard
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-07 04:35:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r . Get ( "/public-dashboards/:accessToken" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-22 04:56:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											hs . PublicDashboardsApi . Middleware . HandleView , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-26 02:56:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											publicdashboardsapi . SetPublicDashboardAccessToken , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-07 04:35:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											publicdashboardsapi . SetPublicDashboardOrgIdOnContext ( hs . PublicDashboardsApi . PublicDashboardService ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											publicdashboardsapi . CountPublicDashboardRequest ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											hs . Index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-07 07:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/explore" ,  authorize ( ac . EvalPermission ( ac . ActionDatasourcesExplore ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/playlists/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/playlists/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-17 16:15:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/alerting/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/alerting/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 23:27:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/library-panels/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 14:29:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/monitoring/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/monitoring/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/alerts-and-incidents" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/alerts-and-incidents/*" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 18:07:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// sign up
 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-07 23:24:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/verify" ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/signup" ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 17:23:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/api/user/signup/options" ,  routing . Wrap ( hs . GetSignUpOptions ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/api/user/signup" ,  quota ( user . QuotaTargetSrv ) ,  quota ( org . QuotaTargetSrv ) ,  routing . Wrap ( hs . SignUp ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/api/user/signup/step2" ,  routing . Wrap ( hs . SignUpStep2 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-20 21:52:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// invited
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-01 00:24:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/api/user/invite/:code" ,  routing . Wrap ( hs . GetInviteInfoByCode ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/api/user/invite/complete" ,  routing . Wrap ( hs . CompleteInvite ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-20 21:52:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-08 16:57:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// reset password
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 00:02:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/user/password/send-reset-email" ,  reqNotSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/user/password/reset" ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-08 16:57:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-03 17:33:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/api/user/password/send-reset-email" ,  routing . Wrap ( hs . SendResetPasswordEmail ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Post ( "/api/user/password/reset" ,  routing . Wrap ( hs . ResetPassword ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-21 20:53:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// dashboard snapshots
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 23:46:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard/snapshot/*" ,  reqNoAuth ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/dashboard/snapshots/" ,  reqSignedIn ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-27 03:34:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-02-05 00:37:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// api renew session based on cookie
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/api/login/ping" ,  quota ( string ( auth . QuotaTargetSrv ) ) ,  routing . Wrap ( hs . LoginAPIPing ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-07 15:25:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 21:17:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// expose plugin file system assets
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-08 14:49:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/public/plugins/:pluginId/*" ,  hs . getPluginAssets ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 21:17:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 22:42:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// add swagger support
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									registerSwaggerUI ( r ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 20:38:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagClientTokenRotation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-23 21:39:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r . Post ( "/api/user/auth-tokens/rotate" ,  routing . Wrap ( hs . RotateUserAuthToken ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r . Get ( "/user/auth-tokens/rotate" ,  routing . Wrap ( hs . RotateUserAuthTokenRedirect ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-13 00:15:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/admin/authentication/" ,  authorize ( evalAuthenticationSettings ( ) ) ,  hs . Index ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 19:13:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// authed api
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Group ( "/api" ,  func ( apiRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 17:47:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// user (signed in)
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/user" ,  func ( userRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-05 16:59:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/" ,  routing . Wrap ( hs . GetSignedInUser ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Put ( "/" ,  routing . Wrap ( hs . UpdateSignedInUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Post ( "/using/:id" ,  routing . Wrap ( hs . UserSetUsingOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Get ( "/orgs" ,  routing . Wrap ( hs . GetSignedInUserOrgList ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Get ( "/teams" ,  routing . Wrap ( hs . GetSignedInUserTeamList ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 22:58:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/stars" ,  routing . Wrap ( hs . starApi . GetStars ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-06 04:32:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Deprecated: use /stars/dashboard/uid/:uid API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 22:58:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// nolint:staticcheck
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Post ( "/stars/dashboard/:id" ,  routing . Wrap ( hs . starApi . StarDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-06 04:32:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Deprecated: use /stars/dashboard/uid/:uid API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 22:58:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// nolint:staticcheck
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Delete ( "/stars/dashboard/:id" ,  routing . Wrap ( hs . starApi . UnstarDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 22:58:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Post ( "/stars/dashboard/uid/:uid" ,  routing . Wrap ( hs . starApi . StarDashboardByUID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Delete ( "/stars/dashboard/uid/:uid" ,  routing . Wrap ( hs . starApi . UnstarDashboardByUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-06 04:32:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Put ( "/password" ,  routing . Wrap ( hs . ChangeUserPassword ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-03 16:20:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/quotas" ,  routing . Wrap ( hs . GetUserQuotas ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Put ( "/helpflags/:id" ,  routing . Wrap ( hs . SetHelpFlag ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// For dev purpose
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/helpflags/clear" ,  routing . Wrap ( hs . ClearHelpFlags ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-03 04:54:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 20:41:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/preferences" ,  routing . Wrap ( hs . GetUserPreferences ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Put ( "/preferences" ,  routing . Wrap ( hs . UpdateUserPreferences ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 20:07:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Patch ( "/preferences" ,  routing . Wrap ( hs . PatchUserPreferences ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 22:15:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:18:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userRoute . Get ( "/auth-tokens" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  routing . Wrap ( hs . GetUserAuthTokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											userRoute . Post ( "/revoke-auth-token" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  routing . Wrap ( hs . RevokeUserAuthToken ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 01:04:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  reqSignedInNoAnonymous ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/users" ,  func ( usersRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 19:48:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userIDScope  :=  ac . Scope ( "global.users" ,  "id" ,  ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											usersRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) ,  routing . Wrap ( hs . searchUsersService . SearchUsers ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Get ( "/search" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) ,  routing . Wrap ( hs . searchUsersService . SearchUsersWithPaging ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Get ( "/:id" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ,  userIDScope ) ) ,  routing . Wrap ( hs . GetUserByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Get ( "/:id/teams" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ,  userIDScope ) ) ,  routing . Wrap ( hs . GetUserTeams ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Get ( "/:id/orgs" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ,  userIDScope ) ) ,  routing . Wrap ( hs . GetUserOrgList ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// query parameters /users/lookup?loginOrEmail=admin@example.com
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											usersRoute . Get ( "/lookup" ,  authorize ( ac . EvalPermission ( ac . ActionUsersRead ,  ac . ScopeGlobalUsersAll ) ) ,  routing . Wrap ( hs . GetUserByLoginOrEmail ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Put ( "/:id" ,  authorize ( ac . EvalPermission ( ac . ActionUsersWrite ,  userIDScope ) ) ,  routing . Wrap ( hs . UpdateUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											usersRoute . Post ( "/:id/using/:orgId" ,  authorize ( ac . EvalPermission ( ac . ActionUsersWrite ,  userIDScope ) ) ,  routing . Wrap ( hs . UpdateUserActiveOrg ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:18:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 01:18:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// org information available to all users.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/org" ,  func ( orgRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsRead ) ) ,  routing . Wrap ( hs . GetCurrentOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Get ( "/quotas" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsQuotasRead ) ) ,  routing . Wrap ( hs . GetCurrentOrgQuotas ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 01:18:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagStorage )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-05 00:40:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Will eventually be replaced with the 'object' route
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 14:26:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											apiRoute . Group ( "/storage" ,  hs . StorageService . RegisterHTTPRoutes ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 06:52:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-05 00:40:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagPanelTitleSearch )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-23 07:02:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											apiRoute . Group ( "/search-v2" ,  hs . SearchV2HTTPService . RegisterHTTPRoutes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 01:18:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// current org
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/org" ,  func ( orgRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-07 17:54:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userIDScope  :=  ac . Scope ( "users" ,  "id" ,  ac . Parameter ( ":userId" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Put ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsWrite ) ) ,  routing . Wrap ( hs . UpdateCurrentOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Put ( "/address" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsWrite ) ) ,  routing . Wrap ( hs . UpdateCurrentOrgAddress ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:18:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/users" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) ,  routing . Wrap ( hs . GetOrgUsersForCurrentOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Get ( "/users/search" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) ,  routing . Wrap ( hs . SearchOrgUsersWithPaging ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Post ( "/users" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ,  ac . ScopeUsersAll ) ) ,  quota ( user . QuotaTargetSrv ) ,  quota ( org . QuotaTargetSrv ) ,  routing . Wrap ( hs . AddOrgUserToCurrentOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Patch ( "/users/:userId" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersWrite ,  userIDScope ) ) ,  routing . Wrap ( hs . UpdateOrgUserForCurrentOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Delete ( "/users/:userId" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersRemove ,  userIDScope ) ) ,  routing . Wrap ( hs . RemoveOrgUserForCurrentOrg ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 15:51:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// invites
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/invites" ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) ,  routing . Wrap ( hs . GetPendingOrgInvites ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Post ( "/invites" ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) ,  quota ( user . QuotaTargetSrv ) ,  quota ( user . QuotaTargetSrv ) ,  routing . Wrap ( hs . AddOrgInvite ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Patch ( "/invites/:code/revoke" ,  authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) ,  routing . Wrap ( hs . RevokeInvite ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-18 13:46:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-03 04:54:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// prefs
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/preferences" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesRead ) ) ,  routing . Wrap ( hs . GetOrgPreferences ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Put ( "/preferences" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) ,  routing . Wrap ( hs . UpdateOrgPreferences ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgRoute . Patch ( "/preferences" ,  authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) ,  routing . Wrap ( hs . PatchOrgPreferences ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 18:19:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 16:16:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-06 20:08:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// current org without requirement of user to be org admin
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/org" ,  func ( orgRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-06 16:31:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											lookupEvaluator  :=  func ( )  ac . Evaluator  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-26 02:40:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  hs . License . FeatureEnabled ( "accesscontrol.enforcement" )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-06 16:31:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													return  ac . EvalPermission ( ac . ActionOrgUsersRead ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// For oss we allow users with access to update permissions on either folders, teams or dashboards to perform the lookup
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  ac . EvalAny ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													ac . EvalPermission ( ac . ActionOrgUsersRead ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													ac . EvalPermission ( ac . ActionTeamsPermissionsWrite ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													ac . EvalPermission ( dashboards . ActionFoldersPermissionsWrite ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-26 02:40:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-06 16:31:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/users/lookup" ,  authorize ( lookupEvaluator ( ) ) ,  routing . Wrap ( hs . GetOrgUsersForCurrentOrgLookup ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-06 20:08:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 16:16:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// create new org
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Post ( "/orgs" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . EvalPermission ( ac . ActionOrgsCreate ) ) ,  quota ( org . QuotaTargetSrv ) ,  routing . Wrap ( hs . CreateOrg ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 16:16:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 17:47:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// search all orgs
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/orgs" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . EvalPermission ( ac . ActionOrgsRead ) ) ,  routing . Wrap ( hs . SearchOrgs ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 17:47:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 16:16:32 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// orgs (admin routes)
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/orgs/:orgId" ,  func ( orgsRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-17 17:12:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											userIDScope  :=  ac . Scope ( "users" ,  "id" ,  ac . Parameter ( ":userId" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgsRoute . Get ( "/" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsRead ) ) ,  routing . Wrap ( hs . GetOrgByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Put ( "/" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsWrite ) ) ,  routing . Wrap ( hs . UpdateOrg ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Put ( "/address" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsWrite ) ) ,  routing . Wrap ( hs . UpdateOrgAddress ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Delete ( "/" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsDelete ) ) ,  routing . Wrap ( hs . DeleteOrgByID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:18:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgsRoute . Get ( "/users" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgUsersRead ) ) ,  routing . Wrap ( hs . GetOrgUsers ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Get ( "/users/search" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgUsersRead ) ) ,  routing . Wrap ( hs . SearchOrgUsers ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Post ( "/users" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgUsersAdd ,  ac . ScopeUsersAll ) ) ,  routing . Wrap ( hs . AddOrgUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Patch ( "/users/:userId" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgUsersWrite ,  userIDScope ) ) ,  routing . Wrap ( hs . UpdateOrgUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Delete ( "/users/:userId" ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgUsersRemove ,  userIDScope ) ) ,  routing . Wrap ( hs . RemoveOrgUser ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgsRoute . Get ( "/quotas" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsQuotasRead ) ) ,  routing . Wrap ( hs . GetOrgQuotas ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											orgsRoute . Put ( "/quotas/:target" ,  authorizeInOrg ( ac . UseOrgFromContextParams ,  ac . EvalPermission ( ac . ActionOrgsQuotasWrite ) ) ,  routing . Wrap ( hs . UpdateOrgQuota ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 18:19:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 03:26:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-13 05:50:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// orgs (admin routes)
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/orgs/name/:name/" ,  authorizeInOrg ( ac . UseGlobalOrg ,  ac . EvalPermission ( ac . ActionOrgsRead ) ) ,  routing . Wrap ( hs . GetOrgByName ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-13 05:50:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:26:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// auth api keys
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/auth/keys" ,  func ( keysRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 02:01:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											apikeyIDScope  :=  ac . Scope ( "apikeys" ,  "id" ,  ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											keysRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionAPIKeyRead ) ) ,  routing . Wrap ( hs . GetAPIKeys ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											keysRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionAPIKeyCreate ) ) ,  quota ( string ( apikey . QuotaTargetSrv ) ) ,  routing . Wrap ( hs . AddAPIKey ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											keysRoute . Delete ( "/:id" ,  authorize ( ac . EvalPermission ( ac . ActionAPIKeyDelete ,  apikeyIDScope ) ) ,  routing . Wrap ( hs . DeleteAPIKey ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:18:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  requestmeta . SetOwner ( requestmeta . TeamAuth ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 03:26:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-17 14:35:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Preferences
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/preferences" ,  func ( prefRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-03 16:20:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											prefRoute . Post ( "/set-home-dash" ,  routing . Wrap ( hs . SetHomeDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-17 14:35:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-11 22:30:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Data sources
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/datasources" ,  func ( datasourceRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:56:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											idScope  :=  datasources . ScopeProvider . GetResourceScope ( ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											uidScope  :=  datasources . ScopeProvider . GetResourceScopeUID ( ac . Parameter ( ":uid" ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											nameScope  :=  datasources . ScopeProvider . GetResourceScopeName ( ac . Parameter ( ":name" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											datasourceRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( datasources . ActionRead ) ) ,  routing . Wrap ( hs . GetDataSources ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( datasources . ActionCreate ) ) ,  quota ( string ( datasources . QuotaTargetSrv ) ) ,  routing . Wrap ( hs . AddDataSource ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Put ( "/:id" ,  authorize ( ac . EvalPermission ( datasources . ActionWrite ,  idScope ) ) ,  routing . Wrap ( hs . UpdateDataSourceByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Put ( "/uid/:uid" ,  authorize ( ac . EvalPermission ( datasources . ActionWrite ,  uidScope ) ) ,  routing . Wrap ( hs . UpdateDataSourceByUID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Delete ( "/:id" ,  authorize ( ac . EvalPermission ( datasources . ActionDelete ,  idScope ) ) ,  routing . Wrap ( hs . DeleteDataSourceById ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Delete ( "/uid/:uid" ,  authorize ( ac . EvalPermission ( datasources . ActionDelete ,  uidScope ) ) ,  routing . Wrap ( hs . DeleteDataSourceByUID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Delete ( "/name/:name" ,  authorize ( ac . EvalPermission ( datasources . ActionDelete ,  nameScope ) ) ,  routing . Wrap ( hs . DeleteDataSourceByName ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Get ( "/:id" ,  authorize ( ac . EvalPermission ( datasources . ActionRead ,  idScope ) ) ,  routing . Wrap ( hs . GetDataSourceById ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Get ( "/uid/:uid" ,  authorize ( ac . EvalPermission ( datasources . ActionRead ,  uidScope ) ) ,  routing . Wrap ( hs . GetDataSourceByUID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Get ( "/name/:name" ,  authorize ( ac . EvalPermission ( datasources . ActionRead ,  nameScope ) ) ,  routing . Wrap ( hs . GetDataSourceByName ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											datasourceRoute . Get ( "/id/:name" ,  authorize ( ac . EvalPermission ( datasources . ActionIDRead ,  nameScope ) ) ,  routing . Wrap ( hs . GetDataSourceIdByName ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-01 21:18:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 17:15:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										pluginIDScope  :=  pluginaccesscontrol . ScopeProvider . GetResourceScope ( ac . Parameter ( ":pluginId" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/plugins" ,  routing . Wrap ( hs . GetPluginList ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 19:24:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/plugins/:pluginId/settings" ,  routing . Wrap ( hs . GetPluginSettingByID ) )  // RBAC check performed in handler for App Plugins
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-08 14:02:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/plugins/:pluginId/markdown/:name" ,  routing . Wrap ( hs . GetPluginMarkdown ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-15 23:37:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/plugins/:pluginId/health" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  routing . Wrap ( hs . CheckHealth ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/plugins/:pluginId/resources" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  pluginIDScope ) ) ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  hs . CallResource ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/plugins/:pluginId/resources/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  pluginIDScope ) ) ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  hs . CallResource ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 02:05:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/plugins/errors" ,  routing . Wrap ( hs . GetPluginErrorsList ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-15 23:37:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Any ( "/plugin-proxy/:pluginId/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  pluginIDScope ) ) ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  hs . ProxyPluginRequest ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/plugin-proxy/:pluginId" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess ,  pluginIDScope ) ) ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  hs . ProxyPluginRequest ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 02:05:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  hs . Cfg . PluginAdminEnabled  &&  ( hs . Features . IsEnabledGlobally ( featuremgmt . FlagManagedPluginsInstall )  ||  ! hs . Cfg . PluginAdminExternalManageEnabled )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 17:13:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											apiRoute . Group ( "/plugins" ,  func ( pluginRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-21 22:09:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												pluginRoute . Post ( "/:pluginId/install" ,  authorizeInOrg ( ac . UseGlobalOrSingleOrg ( hs . Cfg ) ,  ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) ,  routing . Wrap ( hs . InstallPlugin ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												pluginRoute . Post ( "/:pluginId/uninstall" ,  authorizeInOrg ( ac . UseGlobalOrSingleOrg ( hs . Cfg ) ,  ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) ,  routing . Wrap ( hs . UninstallPlugin ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-09 15:44:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 17:13:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-11 16:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/plugins" ,  func ( pluginRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-15 23:37:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											pluginRoute . Get ( "/:pluginId/dashboards/" ,  reqOrgAdmin ,  checkAppEnabled ( hs . pluginStore ,  hs . PluginSettings ) ,  routing . Wrap ( hs . GetPluginDashboards ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											pluginRoute . Post ( "/:pluginId/settings" ,  authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionWrite ,  pluginIDScope ) ) ,  routing . Wrap ( hs . UpdatePluginSetting ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-09 15:44:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											pluginRoute . Get ( "/:pluginId/metrics" ,  reqOrgAdmin ,  routing . Wrap ( hs . CollectPluginMetrics ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 04:50:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  hs . Features . IsEnabledGlobally ( featuremgmt . FlagFeatureToggleAdminPage )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 04:12:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											apiRoute . Group ( "/featuremgmt" ,  func ( featuremgmtRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 18:54:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												featuremgmtRoute . Get ( "/state" ,  authorize ( ac . EvalPermission ( ac . ActionFeatureManagementRead ) ) ,  hs . GetFeatureMgmtState ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 04:12:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												featuremgmtRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionFeatureManagementRead ) ) ,  hs . GetFeatureToggles ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-09 23:32:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												featuremgmtRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionFeatureManagementWrite ) ) ,  hs . UpdateFeatureToggle ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 04:12:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-09 23:47:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/frontend/settings/" ,  hs . GetFrontendSettings ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/proxy/:id/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . ProxyDataSourceRequest ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/proxy/uid/:uid/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . ProxyDataSourceRequestWithUID ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/proxy/:id" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . ProxyDataSourceRequest ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/proxy/uid/:uid" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . ProxyDataSourceRequestWithUID ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-20 00:27:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Deprecated: use /datasources/uid/:uid/resources API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/:id/resources" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . CallDatasourceResource ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/uid/:uid/resources" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . CallDatasourceResourceWithUID ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-20 00:27:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Deprecated: use /datasources/uid/:uid/resources/* API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/:id/resources/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . CallDatasourceResource ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/uid/:uid/resources/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  hs . CallDatasourceResourceWithUID ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-20 00:27:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Deprecated: use /datasources/uid/:uid/health API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/:id/health" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  routing . Wrap ( hs . CheckDatasourceHealth ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Any ( "/datasources/uid/:uid/health" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  routing . Wrap ( hs . CheckDatasourceHealthWithUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-10 17:19:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-29 20:51:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Folders
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/folders" ,  func ( folderRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 21:14:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											idScope  :=  dashboards . ScopeFoldersProvider . GetResourceScope ( ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											uidScope  :=  dashboards . ScopeFoldersProvider . GetResourceScopeUID ( ac . Parameter ( ":uid" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											folderRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead ) ) ,  routing . Wrap ( hs . GetFolders ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											folderRoute . Get ( "/id/:id" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead ,  idScope ) ) ,  routing . Wrap ( hs . GetFolderByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											folderRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersCreate ) ) ,  routing . Wrap ( hs . CreateFolder ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-20 22:25:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											folderRoute . Group ( "/:uid" ,  func ( folderUidRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												folderUidRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead ,  uidScope ) ) ,  routing . Wrap ( hs . GetFolderByUID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												folderUidRoute . Put ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersWrite ,  uidScope ) ) ,  routing . Wrap ( hs . UpdateFolder ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												folderUidRoute . Post ( "/move" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersWrite ,  uidScope ) ) ,  routing . Wrap ( hs . MoveFolder ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												folderUidRoute . Delete ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersDelete ,  uidScope ) ) ,  routing . Wrap ( hs . DeleteFolder ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												folderUidRoute . Get ( "/counts" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead ,  uidScope ) ) ,  routing . Wrap ( hs . GetFolderDescendantCounts ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-20 22:25:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												folderUidRoute . Group ( "/permissions" ,  func ( folderPermissionRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													folderPermissionRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersPermissionsRead ,  uidScope ) ) ,  routing . Wrap ( hs . GetFolderPermissionList ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													folderPermissionRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionFoldersPermissionsWrite ,  uidScope ) ) ,  routing . Wrap ( hs . UpdateFolderPermissions ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-20 22:25:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-29 20:51:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Dashboard
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/dashboards" ,  func ( dashboardRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Get ( "/uid/:uid" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsRead ) ) ,  routing . Wrap ( hs . GetDashboard ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											dashboardRoute . Delete ( "/uid/:uid" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsDelete ) ) ,  routing . Wrap ( hs . DeleteDashboardByUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 22:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Group ( "/uid/:uid" ,  func ( dashUidRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												dashUidRoute . Get ( "/versions" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . GetDashboardVersions ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												dashUidRoute . Post ( "/restore" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . RestoreDashboardVersion ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												dashUidRoute . Get ( "/versions/:id" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . GetDashboardVersion ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 22:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												dashUidRoute . Group ( "/permissions" ,  func ( dashboardPermissionRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													dashboardPermissionRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) ,  routing . Wrap ( hs . GetDashboardPermissionList ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													dashboardPermissionRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) ,  routing . Wrap ( hs . UpdateDashboardPermissions ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 22:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-30 04:23:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Post ( "/calculate-diff" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . CalculateDashboardDiff ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-07 17:50:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Post ( "/db" ,  authorize ( ac . EvalAny ( ac . EvalPermission ( dashboards . ActionDashboardsCreate ) ,  ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ) ,  routing . Wrap ( hs . PostDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Get ( "/home" ,  routing . Wrap ( hs . GetHomeDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 19:43:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Get ( "/tags" ,  hs . GetDashboardTags ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 23:38:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-17 00:59:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Deprecated: used to convert internal IDs to UIDs
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Get ( "/ids/:ids" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsRead ) ) ,  hs . GetDashboardUIDs ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-17 00:59:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 22:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Deprecated: use /uid/:uid API instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Group ( "/id/:dashboardId" ,  func ( dashIdRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												dashIdRoute . Get ( "/versions" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . GetDashboardVersions ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												dashIdRoute . Get ( "/versions/:id" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . GetDashboardVersion ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												dashIdRoute . Post ( "/restore" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ,  routing . Wrap ( hs . RestoreDashboardVersion ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 23:38:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												dashIdRoute . Group ( "/permissions" ,  func ( dashboardPermissionRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													dashboardPermissionRoute . Get ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) ,  routing . Wrap ( hs . GetDashboardPermissionList ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													dashboardPermissionRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) ,  routing . Wrap ( hs . UpdateDashboardPermissions ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 23:38:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 03:26:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-19 21:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Dashboard snapshots
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/dashboard/snapshots" ,  func ( dashboardRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 00:57:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											dashboardRoute . Get ( "/" ,  routing . Wrap ( hs . SearchDashboardSnapshots ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-19 21:05:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-19 17:37:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 18:07:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Playlist
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-01 01:26:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										hs . registerPlaylistAPI ( apiRoute ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 18:07:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Search
 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/search/sorting" ,  routing . Wrap ( hs . ListSortOptions ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 01:46:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/search/" ,  routing . Wrap ( hs . Search ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 03:26:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 21:25:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// metrics
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-01 07:22:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// DataSource w/ expressions
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Post ( "/ds/query" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) ,  routing . Wrap ( hs . QueryMetricsV2 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-01 07:22:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/alerts" ,  func ( alertsRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertsRoute . Post ( "/test" ,  routing . Wrap ( hs . AlertTest ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-12 15:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertsRoute . Post ( "/:alertId/pause" ,  reqEditorRole ,  routing . Wrap ( hs . PauseAlert ( setting . AlertingEnabled ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertsRoute . Get ( "/:alertId" ,  hs . ValidateOrgAlert ,  routing . Wrap ( hs . GetAlert ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertsRoute . Get ( "/" ,  routing . Wrap ( hs . GetAlerts ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertsRoute . Get ( "/states-for-dashboard" ,  routing . Wrap ( hs . GetAlertStatesForDashboard ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  requestmeta . SetOwner ( requestmeta . TeamAlerting ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-26 23:36:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-07 00:24:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  notifiersAuthHandler  web . Handler 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  hs . Cfg . UnifiedAlerting . IsEnabled ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											notifiersAuthHandler  =  reqSignedIn 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											notifiersAuthHandler  =  reqEditorRole 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/alert-notifiers" ,  notifiersAuthHandler ,  requestmeta . SetOwner ( requestmeta . TeamAlerting ) ,  routing . Wrap ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											hs . GetAlertNotifiers ( hs . Cfg . UnifiedAlerting . IsEnabled ( ) ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 19:58:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-14 19:32:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/alert-notifications" ,  func ( alertNotifications  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertNotifications . Get ( "/" ,  routing . Wrap ( hs . GetAlertNotifications ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertNotifications . Post ( "/test" ,  routing . Wrap ( hs . NotificationTest ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertNotifications . Post ( "/" ,  routing . Wrap ( hs . CreateAlertNotification ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertNotifications . Put ( "/:notificationId" ,  routing . Wrap ( hs . UpdateAlertNotification ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertNotifications . Get ( "/:notificationId" ,  routing . Wrap ( hs . GetAlertNotificationByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertNotifications . Delete ( "/:notificationId" ,  routing . Wrap ( hs . DeleteAlertNotification ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											alertNotifications . Get ( "/uid/:uid" ,  routing . Wrap ( hs . GetAlertNotificationByUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertNotifications . Put ( "/uid/:uid" ,  routing . Wrap ( hs . UpdateAlertNotificationByUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											alertNotifications . Delete ( "/uid/:uid" ,  routing . Wrap ( hs . DeleteAlertNotificationByUID ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  reqEditorRole ,  requestmeta . SetOwner ( requestmeta . TeamAlerting ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-14 19:32:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-13 02:03:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// alert notifications without requirement of user to be org editor
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Group ( "/alert-notifications" ,  func ( orgRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-04 20:41:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											orgRoute . Get ( "/lookup" ,  routing . Wrap ( hs . GetAlertNotificationLookup ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-16 21:05:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  requestmeta . SetOwner ( requestmeta . TeamAlerting ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-13 02:03:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Get ( "/annotations" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead ) ) ,  routing . Wrap ( hs . GetAnnotations ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										apiRoute . Post ( "/annotations/mass-delete" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsDelete ) ) ,  routing . Wrap ( hs . MassDeleteAnnotations ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-12 21:46:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/annotations" ,  func ( annotationsRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											annotationsRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsCreate ) ) ,  routing . Wrap ( hs . PostAnnotation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Get ( "/:annotationId" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead ,  ac . ScopeAnnotationsID ) ) ,  routing . Wrap ( hs . GetAnnotationByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Delete ( "/:annotationId" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsDelete ,  ac . ScopeAnnotationsID ) ) ,  routing . Wrap ( hs . DeleteAnnotationByID ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Put ( "/:annotationId" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsWrite ,  ac . ScopeAnnotationsID ) ) ,  routing . Wrap ( hs . UpdateAnnotation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Patch ( "/:annotationId" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsWrite ,  ac . ScopeAnnotationsID ) ) ,  routing . Wrap ( hs . PatchAnnotation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Post ( "/graphite" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsCreate ,  ac . ScopeAnnotationsTypeOrganization ) ) ,  routing . Wrap ( hs . PostGraphiteAnnotation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											annotationsRoute . Get ( "/tags" ,  authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead ) ) ,  routing . Wrap ( hs . GetAnnotationTags ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-21 07:52:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-08 17:25:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Post ( "/frontend-metrics" ,  routing . Wrap ( hs . PostFrontendMetrics ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 02:04:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 23:44:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Group ( "/live" ,  func ( liveRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// the channel path is in the name
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											liveRoute . Post ( "/publish" ,  routing . Wrap ( hs . Live . HandleHTTPPublish ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 00:04:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 00:19:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// POST influx line protocol.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 23:44:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											liveRoute . Post ( "/push/:streamId" ,  hs . LivePushGateway . Handle ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 00:04:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 23:44:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// List available streams and fields
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											liveRoute . Get ( "/list" ,  routing . Wrap ( hs . Live . HandleListHTTP ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 03:55:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 23:44:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Some channels may have info
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											liveRoute . Get ( "/info/*" ,  routing . Wrap ( hs . Live . HandleInfoHTTP ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:52:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupNone ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-30 18:23:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 18:48:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// short urls
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										apiRoute . Post ( "/short-urls" ,  routing . Wrap ( hs . createShortURL ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-15 19:16:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ,  reqSignedIn ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// admin api
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 22:36:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Group ( "/api/admin" ,  func ( adminRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-21 00:58:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// There is additional filter which will ensure that user sees only settings that they are allowed to see, so we don't need provide additional scope here for ActionSettingsRead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Get ( "/settings" ,  authorize ( ac . EvalPermission ( ac . ActionSettingsRead ) ) ,  routing . Wrap ( hs . AdminGetSettings ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Get ( "/settings-verbose" ,  authorize ( ac . EvalPermission ( ac . ActionSettingsRead ) ) ,  routing . Wrap ( hs . AdminGetVerboseSettings ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Get ( "/stats" ,  authorize ( ac . EvalPermission ( ac . ActionServerStatsRead ) ) ,  routing . Wrap ( hs . AdminGetStats ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-12 15:01:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Post ( "/pause-all-alerts" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . PauseAllAlerts ( setting . AlertingEnabled ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 18:19:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-23 19:13:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/rotate-data-keys" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminRotateDataEncryptionKeys ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-18 14:57:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/reencrypt-data-keys" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminReEncryptEncryptionKeys ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/reencrypt-secrets" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminReEncryptSecrets ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/rollback-secrets" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminRollbackSecrets ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 02:44:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/migrate-secrets/to-plugin" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminMigrateSecretsToPlugin ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/migrate-secrets/from-plugin" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminMigrateSecretsFromPlugin ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/encryption/delete-secretsmanagerplugin-secrets" ,  reqGrafanaAdmin ,  routing . Wrap ( hs . AdminDeleteAllSecretsManagerPluginSecrets ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-23 19:13:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminRoute . Post ( "/provisioning/dashboards/reload" ,  authorize ( ac . EvalPermission ( ActionProvisioningReload ,  ScopeProvisionersDashboards ) ) ,  routing . Wrap ( hs . AdminProvisioningReloadDashboards ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/provisioning/plugins/reload" ,  authorize ( ac . EvalPermission ( ActionProvisioningReload ,  ScopeProvisionersPlugins ) ) ,  routing . Wrap ( hs . AdminProvisioningReloadPlugins ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/provisioning/datasources/reload" ,  authorize ( ac . EvalPermission ( ActionProvisioningReload ,  ScopeProvisionersDatasources ) ) ,  routing . Wrap ( hs . AdminProvisioningReloadDatasources ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/provisioning/notifications/reload" ,  authorize ( ac . EvalPermission ( ActionProvisioningReload ,  ScopeProvisionersNotifications ) ) ,  routing . Wrap ( hs . AdminProvisioningReloadNotifications ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminRoute . Post ( "/provisioning/alerting/reload" ,  authorize ( ac . EvalPermission ( ActionProvisioningReload ,  ScopeProvisionersAlertRules ) ) ,  routing . Wrap ( hs . AdminProvisioningReloadAlerting ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-26 17:50:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ,  reqSignedIn ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 22:31:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Administering users
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Group ( "/api/admin/users" ,  func ( adminUserRoute  routing . RouteRegister )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 19:48:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										userIDScope  :=  ac . Scope ( "global.users" ,  "id" ,  ac . Parameter ( ":id" ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-24 17:36:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:49:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										adminUserRoute . Post ( "/" ,  authorize ( ac . EvalPermission ( ac . ActionUsersCreate ) ) ,  routing . Wrap ( hs . AdminCreateUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Put ( "/:id/password" ,  authorize ( ac . EvalPermission ( ac . ActionUsersPasswordUpdate ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminUpdateUserPassword ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Put ( "/:id/permissions" ,  authorize ( ac . EvalPermission ( ac . ActionUsersPermissionsUpdate ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminUpdateUserPermissions ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Delete ( "/:id" ,  authorize ( ac . EvalPermission ( ac . ActionUsersDelete ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminDeleteUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Post ( "/:id/disable" ,  authorize ( ac . EvalPermission ( ac . ActionUsersDisable ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminDisableUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Post ( "/:id/enable" ,  authorize ( ac . EvalPermission ( ac . ActionUsersEnable ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminEnableUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Get ( "/:id/quotas" ,  authorize ( ac . EvalPermission ( ac . ActionUsersQuotasList ,  userIDScope ) ) ,  routing . Wrap ( hs . GetUserQuotas ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Put ( "/:id/quotas/:target" ,  authorize ( ac . EvalPermission ( ac . ActionUsersQuotasUpdate ,  userIDScope ) ) ,  routing . Wrap ( hs . UpdateUserQuota ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Post ( "/:id/logout" ,  authorize ( ac . EvalPermission ( ac . ActionUsersLogout ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminLogoutUser ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Get ( "/:id/auth-tokens" ,  authorize ( ac . EvalPermission ( ac . ActionUsersAuthTokenList ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminGetUserAuthTokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										adminUserRoute . Post ( "/:id/revoke-auth-token" ,  authorize ( ac . EvalPermission ( ac . ActionUsersAuthTokenUpdate ,  userIDScope ) ) ,  routing . Wrap ( hs . AdminRevokeUserAuthToken ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-26 17:50:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ,  reqSignedIn ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 22:31:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// rendering
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 01:11:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/render/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  reqSignedIn ,  hs . RenderToPng ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-06 16:11:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-09 04:42:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// grafana.net proxy
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 01:11:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Any ( "/api/gnet/*" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  reqSignedIn ,  hs . ProxyGnetRequest ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-09 04:42:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-07 07:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Gravatar service
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 01:11:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/avatar/:hash" ,  requestmeta . SetSLOGroup ( requestmeta . SLOGroupHighSlow ) ,  hs . AvatarCacheServer . Handler ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-21 06:51:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-02 21:15:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Snapshots
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 00:57:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Post ( "/api/snapshots/" ,  reqSnapshotPublicModeOrSignedIn ,  hs . CreateDashboardSnapshot ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-26 21:28:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/api/snapshot/shared-options/" ,  reqSignedIn ,  hs . GetSharingOptions ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 00:57:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Get ( "/api/snapshots/:key" ,  routing . Wrap ( hs . GetDashboardSnapshot ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r . Get ( "/api/snapshots-delete/:deleteKey" ,  reqSnapshotPublicModeOrSignedIn ,  routing . Wrap ( hs . DeleteDashboardSnapshotByDeleteKey ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 03:13:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r . Delete ( "/api/snapshots/:key" ,  reqSignedIn ,  routing . Wrap ( hs . DeleteDashboardSnapshot ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 04:25:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-07-13 00:15:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  evalAuthenticationSettings ( )  ac . Evaluator  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ac . EvalAny ( ac . EvalAll ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ac . EvalPermission ( ac . ActionSettingsWrite ,  ac . ScopeSettingsSAML ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ac . EvalPermission ( ac . ActionSettingsRead ,  ac . ScopeSettingsSAML ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) ,  ac . EvalPermission ( ac . ActionLDAPStatusRead ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}