|
|
|
@ -15,7 +15,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true}) |
|
|
|
|
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN) |
|
|
|
|
reqOrgAdmin := middleware.RoleAuth(m.ROLE_ADMIN) |
|
|
|
|
redirectFromLegacyDashboardUrl := middleware.RedirectFromLegacyDashboardUrl() |
|
|
|
|
redirectFromLegacyDashboardUrl := middleware.RedirectFromLegacyDashboardURL() |
|
|
|
|
redirectFromLegacyDashboardSoloUrl := middleware.RedirectFromLegacyDashboardSoloUrl() |
|
|
|
|
quota := middleware.Quota |
|
|
|
|
bind := binding.Bind |
|
|
|
@ -110,7 +110,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
r.Get("/api/snapshots-delete/:key", reqEditorRole, wrap(DeleteDashboardSnapshot)) |
|
|
|
|
|
|
|
|
|
// api renew session based on remember cookie
|
|
|
|
|
r.Get("/api/login/ping", quota("session"), LoginApiPing) |
|
|
|
|
r.Get("/api/login/ping", quota("session"), LoginAPIPing) |
|
|
|
|
|
|
|
|
|
// authed api
|
|
|
|
|
r.Group("/api", func(apiRoute RouteRegister) { |
|
|
|
@ -139,7 +139,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
apiRoute.Group("/users", func(usersRoute RouteRegister) { |
|
|
|
|
usersRoute.Get("/", wrap(SearchUsers)) |
|
|
|
|
usersRoute.Get("/search", wrap(SearchUsersWithPaging)) |
|
|
|
|
usersRoute.Get("/:id", wrap(GetUserById)) |
|
|
|
|
usersRoute.Get("/:id", wrap(GetUserByID)) |
|
|
|
|
usersRoute.Get("/:id/orgs", wrap(GetUserOrgList)) |
|
|
|
|
// query parameters /users/lookup?loginOrEmail=admin@example.com
|
|
|
|
|
usersRoute.Get("/lookup", wrap(GetUserByLoginOrEmail)) |
|
|
|
@ -149,11 +149,11 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// team (admin permission required)
|
|
|
|
|
apiRoute.Group("/teams", func(teamsRoute RouteRegister) { |
|
|
|
|
teamsRoute.Get("/:teamId", wrap(GetTeamById)) |
|
|
|
|
teamsRoute.Get("/:teamId", wrap(GetTeamByID)) |
|
|
|
|
teamsRoute.Get("/search", wrap(SearchTeams)) |
|
|
|
|
teamsRoute.Post("/", bind(m.CreateTeamCommand{}), wrap(CreateTeam)) |
|
|
|
|
teamsRoute.Put("/:teamId", bind(m.UpdateTeamCommand{}), wrap(UpdateTeam)) |
|
|
|
|
teamsRoute.Delete("/:teamId", wrap(DeleteTeamById)) |
|
|
|
|
teamsRoute.Delete("/:teamId", wrap(DeleteTeamByID)) |
|
|
|
|
teamsRoute.Get("/:teamId/members", wrap(GetTeamMembers)) |
|
|
|
|
teamsRoute.Post("/:teamId/members", bind(m.AddTeamMemberCommand{}), wrap(AddTeamMember)) |
|
|
|
|
teamsRoute.Delete("/:teamId/members/:userId", wrap(RemoveTeamMember)) |
|
|
|
@ -192,10 +192,10 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// orgs (admin routes)
|
|
|
|
|
apiRoute.Group("/orgs/:orgId", func(orgsRoute RouteRegister) { |
|
|
|
|
orgsRoute.Get("/", wrap(GetOrgById)) |
|
|
|
|
orgsRoute.Get("/", wrap(GetOrgByID)) |
|
|
|
|
orgsRoute.Put("/", bind(dtos.UpdateOrgForm{}), wrap(UpdateOrg)) |
|
|
|
|
orgsRoute.Put("/address", bind(dtos.UpdateOrgAddressForm{}), wrap(UpdateOrgAddress)) |
|
|
|
|
orgsRoute.Delete("/", wrap(DeleteOrgById)) |
|
|
|
|
orgsRoute.Delete("/", wrap(DeleteOrgByID)) |
|
|
|
|
orgsRoute.Get("/users", wrap(GetOrgUsers)) |
|
|
|
|
orgsRoute.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser)) |
|
|
|
|
orgsRoute.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUser)) |
|
|
|
@ -211,9 +211,9 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// auth api keys
|
|
|
|
|
apiRoute.Group("/auth/keys", func(keysRoute RouteRegister) { |
|
|
|
|
keysRoute.Get("/", wrap(GetApiKeys)) |
|
|
|
|
keysRoute.Post("/", quota("api_key"), bind(m.AddApiKeyCommand{}), wrap(AddApiKey)) |
|
|
|
|
keysRoute.Delete("/:id", wrap(DeleteApiKey)) |
|
|
|
|
keysRoute.Get("/", wrap(GetAPIKeys)) |
|
|
|
|
keysRoute.Post("/", quota("api_key"), bind(m.AddApiKeyCommand{}), wrap(AddAPIKey)) |
|
|
|
|
keysRoute.Delete("/:id", wrap(DeleteAPIKey)) |
|
|
|
|
}, reqOrgAdmin) |
|
|
|
|
|
|
|
|
|
// Preferences
|
|
|
|
@ -226,16 +226,16 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
datasourceRoute.Get("/", wrap(GetDataSources)) |
|
|
|
|
datasourceRoute.Post("/", quota("data_source"), bind(m.AddDataSourceCommand{}), wrap(AddDataSource)) |
|
|
|
|
datasourceRoute.Put("/:id", bind(m.UpdateDataSourceCommand{}), wrap(UpdateDataSource)) |
|
|
|
|
datasourceRoute.Delete("/:id", wrap(DeleteDataSourceById)) |
|
|
|
|
datasourceRoute.Delete("/:id", wrap(DeleteDataSourceByID)) |
|
|
|
|
datasourceRoute.Delete("/name/:name", wrap(DeleteDataSourceByName)) |
|
|
|
|
datasourceRoute.Get("/:id", wrap(GetDataSourceById)) |
|
|
|
|
datasourceRoute.Get("/:id", wrap(GetDataSourceByID)) |
|
|
|
|
datasourceRoute.Get("/name/:name", wrap(GetDataSourceByName)) |
|
|
|
|
}, reqOrgAdmin) |
|
|
|
|
|
|
|
|
|
apiRoute.Get("/datasources/id/:name", wrap(GetDataSourceIdByName), reqSignedIn) |
|
|
|
|
apiRoute.Get("/datasources/id/:name", wrap(GetDataSourceIDByName), reqSignedIn) |
|
|
|
|
|
|
|
|
|
apiRoute.Get("/plugins", wrap(GetPluginList)) |
|
|
|
|
apiRoute.Get("/plugins/:pluginId/settings", wrap(GetPluginSettingById)) |
|
|
|
|
apiRoute.Get("/plugins/:pluginId/settings", wrap(GetPluginSettingByID)) |
|
|
|
|
apiRoute.Get("/plugins/:pluginId/markdown/:name", wrap(GetPluginMarkdown)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/plugins", func(pluginRoute RouteRegister) { |
|
|
|
@ -250,11 +250,11 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
// Folders
|
|
|
|
|
apiRoute.Group("/folders", func(folderRoute RouteRegister) { |
|
|
|
|
folderRoute.Get("/", wrap(GetFolders)) |
|
|
|
|
folderRoute.Get("/id/:id", wrap(GetFolderById)) |
|
|
|
|
folderRoute.Get("/id/:id", wrap(GetFolderByID)) |
|
|
|
|
folderRoute.Post("/", bind(m.CreateFolderCommand{}), wrap(CreateFolder)) |
|
|
|
|
|
|
|
|
|
folderRoute.Group("/:uid", func(folderUidRoute RouteRegister) { |
|
|
|
|
folderUidRoute.Get("/", wrap(GetFolderByUid)) |
|
|
|
|
folderUidRoute.Get("/", wrap(GetFolderByUID)) |
|
|
|
|
folderUidRoute.Put("/", bind(m.UpdateFolderCommand{}), wrap(UpdateFolder)) |
|
|
|
|
folderUidRoute.Delete("/", wrap(DeleteFolder)) |
|
|
|
|
|
|
|
|
@ -268,7 +268,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
// Dashboard
|
|
|
|
|
apiRoute.Group("/dashboards", func(dashboardRoute RouteRegister) { |
|
|
|
|
dashboardRoute.Get("/uid/:uid", wrap(GetDashboard)) |
|
|
|
|
dashboardRoute.Delete("/uid/:uid", wrap(DeleteDashboardByUid)) |
|
|
|
|
dashboardRoute.Delete("/uid/:uid", wrap(DeleteDashboardByUID)) |
|
|
|
|
|
|
|
|
|
dashboardRoute.Get("/db/:slug", wrap(GetDashboard)) |
|
|
|
|
dashboardRoute.Delete("/db/:slug", wrap(DeleteDashboard)) |
|
|
|
@ -314,7 +314,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
// metrics
|
|
|
|
|
apiRoute.Post("/tsdb/query", bind(dtos.MetricRequest{}), wrap(QueryMetrics)) |
|
|
|
|
apiRoute.Get("/tsdb/testdata/scenarios", wrap(GetTestDataScenarios)) |
|
|
|
|
apiRoute.Get("/tsdb/testdata/gensql", reqGrafanaAdmin, wrap(GenerateSqlTestData)) |
|
|
|
|
apiRoute.Get("/tsdb/testdata/gensql", reqGrafanaAdmin, wrap(GenerateSQLTestData)) |
|
|
|
|
apiRoute.Get("/tsdb/testdata/random-walk", wrap(GetTestDataRandomWalk)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/alerts", func(alertsRoute RouteRegister) { |
|
|
|
@ -332,7 +332,7 @@ func (hs *HttpServer) registerRoutes() { |
|
|
|
|
alertNotifications.Post("/test", bind(dtos.NotificationTestCommand{}), wrap(NotificationTest)) |
|
|
|
|
alertNotifications.Post("/", bind(m.CreateAlertNotificationCommand{}), wrap(CreateAlertNotification)) |
|
|
|
|
alertNotifications.Put("/:notificationId", bind(m.UpdateAlertNotificationCommand{}), wrap(UpdateAlertNotification)) |
|
|
|
|
alertNotifications.Get("/:notificationId", wrap(GetAlertNotificationById)) |
|
|
|
|
alertNotifications.Get("/:notificationId", wrap(GetAlertNotificationByID)) |
|
|
|
|
alertNotifications.Delete("/:notificationId", wrap(DeleteAlertNotification)) |
|
|
|
|
}, reqEditorRole) |
|
|
|
|
|
|
|
|
|