|
@@ -15,6 +15,8 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
|
|
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
|
|
|
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
|
|
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
|
|
|
reqOrgAdmin := middleware.RoleAuth(m.ROLE_ADMIN)
|
|
reqOrgAdmin := middleware.RoleAuth(m.ROLE_ADMIN)
|
|
|
|
|
+ redirectFromLegacyDashboardUrl := middleware.RedirectFromLegacyDashboardUrl()
|
|
|
|
|
+ redirectFromLegacyDashboardSoloUrl := middleware.RedirectFromLegacyDashboardSoloUrl()
|
|
|
quota := middleware.Quota
|
|
quota := middleware.Quota
|
|
|
bind := binding.Bind
|
|
bind := binding.Bind
|
|
|
|
|
|
|
@@ -40,9 +42,14 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
r.Get("/datasources/", reqSignedIn, Index)
|
|
r.Get("/datasources/", reqSignedIn, Index)
|
|
|
r.Get("/datasources/new", reqSignedIn, Index)
|
|
r.Get("/datasources/new", reqSignedIn, Index)
|
|
|
r.Get("/datasources/edit/*", reqSignedIn, Index)
|
|
r.Get("/datasources/edit/*", reqSignedIn, Index)
|
|
|
- r.Get("/org/users/", reqSignedIn, Index)
|
|
|
|
|
|
|
+ r.Get("/org/users", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/org/users/new", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/org/users/invite", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/org/teams", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/org/teams/*", reqSignedIn, Index)
|
|
|
r.Get("/org/apikeys/", reqSignedIn, Index)
|
|
r.Get("/org/apikeys/", reqSignedIn, Index)
|
|
|
r.Get("/dashboard/import/", reqSignedIn, Index)
|
|
r.Get("/dashboard/import/", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/configuration", reqGrafanaAdmin, Index)
|
|
|
r.Get("/admin", reqGrafanaAdmin, Index)
|
|
r.Get("/admin", reqGrafanaAdmin, Index)
|
|
|
r.Get("/admin/settings", reqGrafanaAdmin, Index)
|
|
r.Get("/admin/settings", reqGrafanaAdmin, Index)
|
|
|
r.Get("/admin/users", reqGrafanaAdmin, Index)
|
|
r.Get("/admin/users", reqGrafanaAdmin, Index)
|
|
@@ -58,10 +65,15 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
r.Get("/plugins/:id/edit", reqSignedIn, Index)
|
|
r.Get("/plugins/:id/edit", reqSignedIn, Index)
|
|
|
r.Get("/plugins/:id/page/:page", reqSignedIn, Index)
|
|
r.Get("/plugins/:id/page/:page", reqSignedIn, Index)
|
|
|
|
|
|
|
|
- r.Get("/dashboard/*", reqSignedIn, Index)
|
|
|
|
|
|
|
+ r.Get("/d/:uid/:slug", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/dashboard/db/:slug", reqSignedIn, redirectFromLegacyDashboardUrl, Index)
|
|
|
|
|
+ r.Get("/dashboard/script/*", reqSignedIn, Index)
|
|
|
r.Get("/dashboard-solo/snapshot/*", Index)
|
|
r.Get("/dashboard-solo/snapshot/*", Index)
|
|
|
- r.Get("/dashboard-solo/*", reqSignedIn, Index)
|
|
|
|
|
|
|
+ r.Get("/d-solo/:uid/:slug", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/dashboard-solo/db/:slug", reqSignedIn, redirectFromLegacyDashboardSoloUrl, Index)
|
|
|
|
|
+ r.Get("/dashboard-solo/script/*", reqSignedIn, Index)
|
|
|
r.Get("/import/dashboard", reqSignedIn, Index)
|
|
r.Get("/import/dashboard", reqSignedIn, Index)
|
|
|
|
|
+ r.Get("/dashboards/", reqSignedIn, Index)
|
|
|
r.Get("/dashboards/*", reqSignedIn, Index)
|
|
r.Get("/dashboards/*", reqSignedIn, Index)
|
|
|
|
|
|
|
|
r.Get("/playlists/", reqSignedIn, Index)
|
|
r.Get("/playlists/", reqSignedIn, Index)
|
|
@@ -94,7 +106,7 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
|
|
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
|
|
|
r.Get("/api/snapshot/shared-options/", GetSharingOptions)
|
|
r.Get("/api/snapshot/shared-options/", GetSharingOptions)
|
|
|
r.Get("/api/snapshots/:key", GetDashboardSnapshot)
|
|
r.Get("/api/snapshots/:key", GetDashboardSnapshot)
|
|
|
- r.Get("/api/snapshots-delete/:key", reqEditorRole, DeleteDashboardSnapshot)
|
|
|
|
|
|
|
+ r.Get("/api/snapshots-delete/:key", reqEditorRole, wrap(DeleteDashboardSnapshot))
|
|
|
|
|
|
|
|
// api renew session based on remember cookie
|
|
// api renew session based on remember cookie
|
|
|
r.Get("/api/login/ping", quota("session"), LoginApiPing)
|
|
r.Get("/api/login/ping", quota("session"), LoginApiPing)
|
|
@@ -134,6 +146,18 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
usersRoute.Post("/:id/using/:orgId", wrap(UpdateUserActiveOrg))
|
|
usersRoute.Post("/:id/using/:orgId", wrap(UpdateUserActiveOrg))
|
|
|
}, reqGrafanaAdmin)
|
|
}, reqGrafanaAdmin)
|
|
|
|
|
|
|
|
|
|
+ // team (admin permission required)
|
|
|
|
|
+ apiRoute.Group("/teams", func(teamsRoute RouteRegister) {
|
|
|
|
|
+ teamsRoute.Get("/:teamId", wrap(GetTeamById))
|
|
|
|
|
+ teamsRoute.Get("/search", wrap(SearchTeams))
|
|
|
|
|
+ teamsRoute.Post("/", quota("teams"), bind(m.CreateTeamCommand{}), wrap(CreateTeam))
|
|
|
|
|
+ teamsRoute.Put("/:teamId", bind(m.UpdateTeamCommand{}), wrap(UpdateTeam))
|
|
|
|
|
+ teamsRoute.Delete("/:teamId", wrap(DeleteTeamById))
|
|
|
|
|
+ teamsRoute.Get("/:teamId/members", wrap(GetTeamMembers))
|
|
|
|
|
+ teamsRoute.Post("/:teamId/members", quota("teams"), bind(m.AddTeamMemberCommand{}), wrap(AddTeamMember))
|
|
|
|
|
+ teamsRoute.Delete("/:teamId/members/:userId", wrap(RemoveTeamMember))
|
|
|
|
|
+ }, reqOrgAdmin)
|
|
|
|
|
+
|
|
|
// org information available to all users.
|
|
// org information available to all users.
|
|
|
apiRoute.Group("/org", func(orgRoute RouteRegister) {
|
|
apiRoute.Group("/org", func(orgRoute RouteRegister) {
|
|
|
orgRoute.Get("/", wrap(GetOrgCurrent))
|
|
orgRoute.Get("/", wrap(GetOrgCurrent))
|
|
@@ -222,21 +246,49 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
apiRoute.Any("/datasources/proxy/:id/*", reqSignedIn, hs.ProxyDataSourceRequest)
|
|
apiRoute.Any("/datasources/proxy/:id/*", reqSignedIn, hs.ProxyDataSourceRequest)
|
|
|
apiRoute.Any("/datasources/proxy/:id", reqSignedIn, hs.ProxyDataSourceRequest)
|
|
apiRoute.Any("/datasources/proxy/:id", reqSignedIn, hs.ProxyDataSourceRequest)
|
|
|
|
|
|
|
|
|
|
+ // Folders
|
|
|
|
|
+ apiRoute.Group("/folders", func(folderRoute RouteRegister) {
|
|
|
|
|
+ folderRoute.Get("/", wrap(GetFolders))
|
|
|
|
|
+ folderRoute.Get("/id/:id", wrap(GetFolderById))
|
|
|
|
|
+ folderRoute.Post("/", bind(m.CreateFolderCommand{}), wrap(CreateFolder))
|
|
|
|
|
+
|
|
|
|
|
+ folderRoute.Group("/:uid", func(folderUidRoute RouteRegister) {
|
|
|
|
|
+ folderUidRoute.Get("/", wrap(GetFolderByUid))
|
|
|
|
|
+ folderUidRoute.Put("/", bind(m.UpdateFolderCommand{}), wrap(UpdateFolder))
|
|
|
|
|
+ folderUidRoute.Delete("/", wrap(DeleteFolder))
|
|
|
|
|
+
|
|
|
|
|
+ folderUidRoute.Group("/permissions", func(folderPermissionRoute RouteRegister) {
|
|
|
|
|
+ folderPermissionRoute.Get("/", wrap(GetFolderPermissionList))
|
|
|
|
|
+ folderPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateFolderPermissions))
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
// Dashboard
|
|
// Dashboard
|
|
|
apiRoute.Group("/dashboards", func(dashboardRoute RouteRegister) {
|
|
apiRoute.Group("/dashboards", func(dashboardRoute RouteRegister) {
|
|
|
- dashboardRoute.Get("/db/:slug", GetDashboard)
|
|
|
|
|
- dashboardRoute.Delete("/db/:slug", reqEditorRole, DeleteDashboard)
|
|
|
|
|
|
|
+ dashboardRoute.Get("/uid/:uid", wrap(GetDashboard))
|
|
|
|
|
+ dashboardRoute.Delete("/uid/:uid", wrap(DeleteDashboardByUid))
|
|
|
|
|
|
|
|
- dashboardRoute.Get("/id/:dashboardId/versions", wrap(GetDashboardVersions))
|
|
|
|
|
- dashboardRoute.Get("/id/:dashboardId/versions/:id", wrap(GetDashboardVersion))
|
|
|
|
|
- dashboardRoute.Post("/id/:dashboardId/restore", reqEditorRole, bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion))
|
|
|
|
|
|
|
+ dashboardRoute.Get("/db/:slug", wrap(GetDashboard))
|
|
|
|
|
+ dashboardRoute.Delete("/db/:slug", wrap(DeleteDashboard))
|
|
|
|
|
|
|
|
dashboardRoute.Post("/calculate-diff", bind(dtos.CalculateDiffOptions{}), wrap(CalculateDashboardDiff))
|
|
dashboardRoute.Post("/calculate-diff", bind(dtos.CalculateDiffOptions{}), wrap(CalculateDashboardDiff))
|
|
|
|
|
|
|
|
- dashboardRoute.Post("/db", reqEditorRole, bind(m.SaveDashboardCommand{}), wrap(PostDashboard))
|
|
|
|
|
|
|
+ dashboardRoute.Post("/db", bind(m.SaveDashboardCommand{}), wrap(PostDashboard))
|
|
|
dashboardRoute.Get("/home", wrap(GetHomeDashboard))
|
|
dashboardRoute.Get("/home", wrap(GetHomeDashboard))
|
|
|
dashboardRoute.Get("/tags", GetDashboardTags)
|
|
dashboardRoute.Get("/tags", GetDashboardTags)
|
|
|
dashboardRoute.Post("/import", bind(dtos.ImportDashboardCommand{}), wrap(ImportDashboard))
|
|
dashboardRoute.Post("/import", bind(dtos.ImportDashboardCommand{}), wrap(ImportDashboard))
|
|
|
|
|
+
|
|
|
|
|
+ dashboardRoute.Group("/id/:dashboardId", func(dashIdRoute RouteRegister) {
|
|
|
|
|
+ dashIdRoute.Get("/versions", wrap(GetDashboardVersions))
|
|
|
|
|
+ dashIdRoute.Get("/versions/:id", wrap(GetDashboardVersion))
|
|
|
|
|
+ dashIdRoute.Post("/restore", bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion))
|
|
|
|
|
+
|
|
|
|
|
+ dashIdRoute.Group("/permissions", func(dashboardPermissionRoute RouteRegister) {
|
|
|
|
|
+ dashboardPermissionRoute.Get("/", wrap(GetDashboardPermissionList))
|
|
|
|
|
+ dashboardPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateDashboardPermissions))
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// Dashboard snapshots
|
|
// Dashboard snapshots
|
|
@@ -291,8 +343,8 @@ func (hs *HttpServer) registerRoutes() {
|
|
|
annotationsRoute.Delete("/:annotationId", wrap(DeleteAnnotationById))
|
|
annotationsRoute.Delete("/:annotationId", wrap(DeleteAnnotationById))
|
|
|
annotationsRoute.Put("/:annotationId", bind(dtos.UpdateAnnotationsCmd{}), wrap(UpdateAnnotation))
|
|
annotationsRoute.Put("/:annotationId", bind(dtos.UpdateAnnotationsCmd{}), wrap(UpdateAnnotation))
|
|
|
annotationsRoute.Delete("/region/:regionId", wrap(DeleteAnnotationRegion))
|
|
annotationsRoute.Delete("/region/:regionId", wrap(DeleteAnnotationRegion))
|
|
|
- annotationsRoute.Post("/graphite", bind(dtos.PostGraphiteAnnotationsCmd{}), wrap(PostGraphiteAnnotation))
|
|
|
|
|
- }, reqEditorRole)
|
|
|
|
|
|
|
+ annotationsRoute.Post("/graphite", reqEditorRole, bind(dtos.PostGraphiteAnnotationsCmd{}), wrap(PostGraphiteAnnotation))
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
// error test
|
|
// error test
|
|
|
r.Get("/metrics/error", wrap(GenerateError))
|
|
r.Get("/metrics/error", wrap(GenerateError))
|