|
|
|
@ -24,7 +24,7 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
// not logged in views
|
|
|
|
|
r.Get("/", reqSignedIn, Index) |
|
|
|
|
r.Get("/logout", Logout) |
|
|
|
|
r.Post("/login", quota("session"), bind(dtos.LoginCommand{}), wrap(LoginPost)) |
|
|
|
|
r.Post("/login", quota("session"), bind(dtos.LoginCommand{}), Wrap(LoginPost)) |
|
|
|
|
r.Get("/login/:name", quota("session"), OAuthLogin) |
|
|
|
|
r.Get("/login", LoginView) |
|
|
|
|
r.Get("/invite/:code", Index) |
|
|
|
@ -83,20 +83,20 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// sign up
|
|
|
|
|
r.Get("/signup", Index) |
|
|
|
|
r.Get("/api/user/signup/options", wrap(GetSignUpOptions)) |
|
|
|
|
r.Post("/api/user/signup", quota("user"), bind(dtos.SignUpForm{}), wrap(SignUp)) |
|
|
|
|
r.Post("/api/user/signup/step2", bind(dtos.SignUpStep2Form{}), wrap(SignUpStep2)) |
|
|
|
|
r.Get("/api/user/signup/options", Wrap(GetSignUpOptions)) |
|
|
|
|
r.Post("/api/user/signup", quota("user"), bind(dtos.SignUpForm{}), Wrap(SignUp)) |
|
|
|
|
r.Post("/api/user/signup/step2", bind(dtos.SignUpStep2Form{}), Wrap(SignUpStep2)) |
|
|
|
|
|
|
|
|
|
// invited
|
|
|
|
|
r.Get("/api/user/invite/:code", wrap(GetInviteInfoByCode)) |
|
|
|
|
r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), wrap(CompleteInvite)) |
|
|
|
|
r.Get("/api/user/invite/:code", Wrap(GetInviteInfoByCode)) |
|
|
|
|
r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), Wrap(CompleteInvite)) |
|
|
|
|
|
|
|
|
|
// reset password
|
|
|
|
|
r.Get("/user/password/send-reset-email", Index) |
|
|
|
|
r.Get("/user/password/reset", Index) |
|
|
|
|
|
|
|
|
|
r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), wrap(SendResetPasswordEmail)) |
|
|
|
|
r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), wrap(ResetPassword)) |
|
|
|
|
r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), Wrap(SendResetPasswordEmail)) |
|
|
|
|
r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), Wrap(ResetPassword)) |
|
|
|
|
|
|
|
|
|
// dashboard snapshots
|
|
|
|
|
r.Get("/dashboard/snapshot/*", Index) |
|
|
|
@ -106,8 +106,8 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot) |
|
|
|
|
r.Get("/api/snapshot/shared-options/", GetSharingOptions) |
|
|
|
|
r.Get("/api/snapshots/:key", GetDashboardSnapshot) |
|
|
|
|
r.Get("/api/snapshots-delete/:deleteKey", wrap(DeleteDashboardSnapshotByDeleteKey)) |
|
|
|
|
r.Delete("/api/snapshots/:key", reqEditorRole, wrap(DeleteDashboardSnapshot)) |
|
|
|
|
r.Get("/api/snapshots-delete/:deleteKey", Wrap(DeleteDashboardSnapshotByDeleteKey)) |
|
|
|
|
r.Delete("/api/snapshots/:key", reqEditorRole, Wrap(DeleteDashboardSnapshot)) |
|
|
|
|
|
|
|
|
|
// api renew session based on remember cookie
|
|
|
|
|
r.Get("/api/login/ping", quota("session"), LoginAPIPing) |
|
|
|
@ -117,138 +117,138 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// user (signed in)
|
|
|
|
|
apiRoute.Group("/user", func(userRoute routing.RouteRegister) { |
|
|
|
|
userRoute.Get("/", wrap(GetSignedInUser)) |
|
|
|
|
userRoute.Put("/", bind(m.UpdateUserCommand{}), wrap(UpdateSignedInUser)) |
|
|
|
|
userRoute.Post("/using/:id", wrap(UserSetUsingOrg)) |
|
|
|
|
userRoute.Get("/orgs", wrap(GetSignedInUserOrgList)) |
|
|
|
|
userRoute.Get("/", Wrap(GetSignedInUser)) |
|
|
|
|
userRoute.Put("/", bind(m.UpdateUserCommand{}), Wrap(UpdateSignedInUser)) |
|
|
|
|
userRoute.Post("/using/:id", Wrap(UserSetUsingOrg)) |
|
|
|
|
userRoute.Get("/orgs", Wrap(GetSignedInUserOrgList)) |
|
|
|
|
|
|
|
|
|
userRoute.Post("/stars/dashboard/:id", wrap(StarDashboard)) |
|
|
|
|
userRoute.Delete("/stars/dashboard/:id", wrap(UnstarDashboard)) |
|
|
|
|
userRoute.Post("/stars/dashboard/:id", Wrap(StarDashboard)) |
|
|
|
|
userRoute.Delete("/stars/dashboard/:id", Wrap(UnstarDashboard)) |
|
|
|
|
|
|
|
|
|
userRoute.Put("/password", bind(m.ChangeUserPasswordCommand{}), wrap(ChangeUserPassword)) |
|
|
|
|
userRoute.Get("/quotas", wrap(GetUserQuotas)) |
|
|
|
|
userRoute.Put("/helpflags/:id", wrap(SetHelpFlag)) |
|
|
|
|
userRoute.Put("/password", bind(m.ChangeUserPasswordCommand{}), Wrap(ChangeUserPassword)) |
|
|
|
|
userRoute.Get("/quotas", Wrap(GetUserQuotas)) |
|
|
|
|
userRoute.Put("/helpflags/:id", Wrap(SetHelpFlag)) |
|
|
|
|
// For dev purpose
|
|
|
|
|
userRoute.Get("/helpflags/clear", wrap(ClearHelpFlags)) |
|
|
|
|
userRoute.Get("/helpflags/clear", Wrap(ClearHelpFlags)) |
|
|
|
|
|
|
|
|
|
userRoute.Get("/preferences", wrap(GetUserPreferences)) |
|
|
|
|
userRoute.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), wrap(UpdateUserPreferences)) |
|
|
|
|
userRoute.Get("/preferences", Wrap(GetUserPreferences)) |
|
|
|
|
userRoute.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), Wrap(UpdateUserPreferences)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// users (admin permission required)
|
|
|
|
|
apiRoute.Group("/users", func(usersRoute routing.RouteRegister) { |
|
|
|
|
usersRoute.Get("/", wrap(SearchUsers)) |
|
|
|
|
usersRoute.Get("/search", wrap(SearchUsersWithPaging)) |
|
|
|
|
usersRoute.Get("/:id", wrap(GetUserByID)) |
|
|
|
|
usersRoute.Get("/:id/orgs", wrap(GetUserOrgList)) |
|
|
|
|
usersRoute.Get("/", Wrap(SearchUsers)) |
|
|
|
|
usersRoute.Get("/search", Wrap(SearchUsersWithPaging)) |
|
|
|
|
usersRoute.Get("/:id", Wrap(GetUserByID)) |
|
|
|
|
usersRoute.Get("/:id/orgs", Wrap(GetUserOrgList)) |
|
|
|
|
// query parameters /users/lookup?loginOrEmail=admin@example.com
|
|
|
|
|
usersRoute.Get("/lookup", wrap(GetUserByLoginOrEmail)) |
|
|
|
|
usersRoute.Put("/:id", bind(m.UpdateUserCommand{}), wrap(UpdateUser)) |
|
|
|
|
usersRoute.Post("/:id/using/:orgId", wrap(UpdateUserActiveOrg)) |
|
|
|
|
usersRoute.Get("/lookup", Wrap(GetUserByLoginOrEmail)) |
|
|
|
|
usersRoute.Put("/:id", bind(m.UpdateUserCommand{}), Wrap(UpdateUser)) |
|
|
|
|
usersRoute.Post("/:id/using/:orgId", Wrap(UpdateUserActiveOrg)) |
|
|
|
|
}, reqGrafanaAdmin) |
|
|
|
|
|
|
|
|
|
// team (admin permission required)
|
|
|
|
|
apiRoute.Group("/teams", func(teamsRoute routing.RouteRegister) { |
|
|
|
|
teamsRoute.Post("/", 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", bind(m.AddTeamMemberCommand{}), wrap(AddTeamMember)) |
|
|
|
|
teamsRoute.Delete("/:teamId/members/:userId", wrap(RemoveTeamMember)) |
|
|
|
|
teamsRoute.Post("/", 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", bind(m.AddTeamMemberCommand{}), Wrap(AddTeamMember)) |
|
|
|
|
teamsRoute.Delete("/:teamId/members/:userId", Wrap(RemoveTeamMember)) |
|
|
|
|
}, reqOrgAdmin) |
|
|
|
|
|
|
|
|
|
// team without requirement of user to be org admin
|
|
|
|
|
apiRoute.Group("/teams", func(teamsRoute routing.RouteRegister) { |
|
|
|
|
teamsRoute.Get("/:teamId", wrap(GetTeamByID)) |
|
|
|
|
teamsRoute.Get("/search", wrap(SearchTeams)) |
|
|
|
|
teamsRoute.Get("/:teamId", Wrap(GetTeamByID)) |
|
|
|
|
teamsRoute.Get("/search", Wrap(SearchTeams)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// org information available to all users.
|
|
|
|
|
apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { |
|
|
|
|
orgRoute.Get("/", wrap(GetOrgCurrent)) |
|
|
|
|
orgRoute.Get("/quotas", wrap(GetOrgQuotas)) |
|
|
|
|
orgRoute.Get("/", Wrap(GetOrgCurrent)) |
|
|
|
|
orgRoute.Get("/quotas", Wrap(GetOrgQuotas)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// current org
|
|
|
|
|
apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { |
|
|
|
|
orgRoute.Put("/", bind(dtos.UpdateOrgForm{}), wrap(UpdateOrgCurrent)) |
|
|
|
|
orgRoute.Put("/address", bind(dtos.UpdateOrgAddressForm{}), wrap(UpdateOrgAddressCurrent)) |
|
|
|
|
orgRoute.Post("/users", quota("user"), bind(m.AddOrgUserCommand{}), wrap(AddOrgUserToCurrentOrg)) |
|
|
|
|
orgRoute.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUserForCurrentOrg)) |
|
|
|
|
orgRoute.Delete("/users/:userId", wrap(RemoveOrgUserForCurrentOrg)) |
|
|
|
|
orgRoute.Put("/", bind(dtos.UpdateOrgForm{}), Wrap(UpdateOrgCurrent)) |
|
|
|
|
orgRoute.Put("/address", bind(dtos.UpdateOrgAddressForm{}), Wrap(UpdateOrgAddressCurrent)) |
|
|
|
|
orgRoute.Post("/users", quota("user"), bind(m.AddOrgUserCommand{}), Wrap(AddOrgUserToCurrentOrg)) |
|
|
|
|
orgRoute.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), Wrap(UpdateOrgUserForCurrentOrg)) |
|
|
|
|
orgRoute.Delete("/users/:userId", Wrap(RemoveOrgUserForCurrentOrg)) |
|
|
|
|
|
|
|
|
|
// invites
|
|
|
|
|
orgRoute.Get("/invites", wrap(GetPendingOrgInvites)) |
|
|
|
|
orgRoute.Post("/invites", quota("user"), bind(dtos.AddInviteForm{}), wrap(AddOrgInvite)) |
|
|
|
|
orgRoute.Patch("/invites/:code/revoke", wrap(RevokeInvite)) |
|
|
|
|
orgRoute.Get("/invites", Wrap(GetPendingOrgInvites)) |
|
|
|
|
orgRoute.Post("/invites", quota("user"), bind(dtos.AddInviteForm{}), Wrap(AddOrgInvite)) |
|
|
|
|
orgRoute.Patch("/invites/:code/revoke", Wrap(RevokeInvite)) |
|
|
|
|
|
|
|
|
|
// prefs
|
|
|
|
|
orgRoute.Get("/preferences", wrap(GetOrgPreferences)) |
|
|
|
|
orgRoute.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), wrap(UpdateOrgPreferences)) |
|
|
|
|
orgRoute.Get("/preferences", Wrap(GetOrgPreferences)) |
|
|
|
|
orgRoute.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), Wrap(UpdateOrgPreferences)) |
|
|
|
|
}, reqOrgAdmin) |
|
|
|
|
|
|
|
|
|
// current org without requirement of user to be org admin
|
|
|
|
|
apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { |
|
|
|
|
orgRoute.Get("/users", wrap(GetOrgUsersForCurrentOrg)) |
|
|
|
|
orgRoute.Get("/users", Wrap(GetOrgUsersForCurrentOrg)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// create new org
|
|
|
|
|
apiRoute.Post("/orgs", quota("org"), bind(m.CreateOrgCommand{}), wrap(CreateOrg)) |
|
|
|
|
apiRoute.Post("/orgs", quota("org"), bind(m.CreateOrgCommand{}), Wrap(CreateOrg)) |
|
|
|
|
|
|
|
|
|
// search all orgs
|
|
|
|
|
apiRoute.Get("/orgs", reqGrafanaAdmin, wrap(SearchOrgs)) |
|
|
|
|
apiRoute.Get("/orgs", reqGrafanaAdmin, Wrap(SearchOrgs)) |
|
|
|
|
|
|
|
|
|
// orgs (admin routes)
|
|
|
|
|
apiRoute.Group("/orgs/:orgId", func(orgsRoute routing.RouteRegister) { |
|
|
|
|
orgsRoute.Get("/", wrap(GetOrgByID)) |
|
|
|
|
orgsRoute.Put("/", bind(dtos.UpdateOrgForm{}), wrap(UpdateOrg)) |
|
|
|
|
orgsRoute.Put("/address", bind(dtos.UpdateOrgAddressForm{}), wrap(UpdateOrgAddress)) |
|
|
|
|
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)) |
|
|
|
|
orgsRoute.Delete("/users/:userId", wrap(RemoveOrgUser)) |
|
|
|
|
orgsRoute.Get("/quotas", wrap(GetOrgQuotas)) |
|
|
|
|
orgsRoute.Put("/quotas/:target", bind(m.UpdateOrgQuotaCmd{}), wrap(UpdateOrgQuota)) |
|
|
|
|
orgsRoute.Get("/", Wrap(GetOrgByID)) |
|
|
|
|
orgsRoute.Put("/", bind(dtos.UpdateOrgForm{}), Wrap(UpdateOrg)) |
|
|
|
|
orgsRoute.Put("/address", bind(dtos.UpdateOrgAddressForm{}), Wrap(UpdateOrgAddress)) |
|
|
|
|
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)) |
|
|
|
|
orgsRoute.Delete("/users/:userId", Wrap(RemoveOrgUser)) |
|
|
|
|
orgsRoute.Get("/quotas", Wrap(GetOrgQuotas)) |
|
|
|
|
orgsRoute.Put("/quotas/:target", bind(m.UpdateOrgQuotaCmd{}), Wrap(UpdateOrgQuota)) |
|
|
|
|
}, reqGrafanaAdmin) |
|
|
|
|
|
|
|
|
|
// orgs (admin routes)
|
|
|
|
|
apiRoute.Group("/orgs/name/:name", func(orgsRoute routing.RouteRegister) { |
|
|
|
|
orgsRoute.Get("/", wrap(GetOrgByName)) |
|
|
|
|
orgsRoute.Get("/", Wrap(GetOrgByName)) |
|
|
|
|
}, reqGrafanaAdmin) |
|
|
|
|
|
|
|
|
|
// auth api keys
|
|
|
|
|
apiRoute.Group("/auth/keys", func(keysRoute routing.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
|
|
|
|
|
apiRoute.Group("/preferences", func(prefRoute routing.RouteRegister) { |
|
|
|
|
prefRoute.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard)) |
|
|
|
|
prefRoute.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), Wrap(SetHomeDashboard)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Data sources
|
|
|
|
|
apiRoute.Group("/datasources", func(datasourceRoute routing.RouteRegister) { |
|
|
|
|
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("/name/:name", wrap(DeleteDataSourceByName)) |
|
|
|
|
datasourceRoute.Get("/:id", wrap(GetDataSourceByID)) |
|
|
|
|
datasourceRoute.Get("/name/:name", wrap(GetDataSourceByName)) |
|
|
|
|
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("/name/:name", Wrap(DeleteDataSourceByName)) |
|
|
|
|
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/markdown/:name", wrap(GetPluginMarkdown)) |
|
|
|
|
apiRoute.Get("/plugins", Wrap(GetPluginList)) |
|
|
|
|
apiRoute.Get("/plugins/:pluginId/settings", Wrap(GetPluginSettingByID)) |
|
|
|
|
apiRoute.Get("/plugins/:pluginId/markdown/:name", Wrap(GetPluginMarkdown)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/plugins", func(pluginRoute routing.RouteRegister) { |
|
|
|
|
pluginRoute.Get("/:pluginId/dashboards/", wrap(GetPluginDashboards)) |
|
|
|
|
pluginRoute.Post("/:pluginId/settings", bind(m.UpdatePluginSettingCmd{}), wrap(UpdatePluginSetting)) |
|
|
|
|
pluginRoute.Get("/:pluginId/dashboards/", Wrap(GetPluginDashboards)) |
|
|
|
|
pluginRoute.Post("/:pluginId/settings", bind(m.UpdatePluginSettingCmd{}), Wrap(UpdatePluginSetting)) |
|
|
|
|
}, reqOrgAdmin) |
|
|
|
|
|
|
|
|
|
apiRoute.Get("/frontend/settings/", GetFrontendSettings) |
|
|
|
@ -257,106 +257,106 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
|
|
|
|
|
// Folders
|
|
|
|
|
apiRoute.Group("/folders", func(folderRoute routing.RouteRegister) { |
|
|
|
|
folderRoute.Get("/", wrap(GetFolders)) |
|
|
|
|
folderRoute.Get("/id/:id", wrap(GetFolderByID)) |
|
|
|
|
folderRoute.Post("/", bind(m.CreateFolderCommand{}), wrap(CreateFolder)) |
|
|
|
|
folderRoute.Get("/", Wrap(GetFolders)) |
|
|
|
|
folderRoute.Get("/id/:id", Wrap(GetFolderByID)) |
|
|
|
|
folderRoute.Post("/", bind(m.CreateFolderCommand{}), Wrap(CreateFolder)) |
|
|
|
|
|
|
|
|
|
folderRoute.Group("/:uid", func(folderUidRoute routing.RouteRegister) { |
|
|
|
|
folderUidRoute.Get("/", wrap(GetFolderByUID)) |
|
|
|
|
folderUidRoute.Put("/", bind(m.UpdateFolderCommand{}), wrap(UpdateFolder)) |
|
|
|
|
folderUidRoute.Delete("/", wrap(DeleteFolder)) |
|
|
|
|
folderUidRoute.Get("/", Wrap(GetFolderByUID)) |
|
|
|
|
folderUidRoute.Put("/", bind(m.UpdateFolderCommand{}), Wrap(UpdateFolder)) |
|
|
|
|
folderUidRoute.Delete("/", Wrap(DeleteFolder)) |
|
|
|
|
|
|
|
|
|
folderUidRoute.Group("/permissions", func(folderPermissionRoute routing.RouteRegister) { |
|
|
|
|
folderPermissionRoute.Get("/", wrap(GetFolderPermissionList)) |
|
|
|
|
folderPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateFolderPermissions)) |
|
|
|
|
folderPermissionRoute.Get("/", Wrap(GetFolderPermissionList)) |
|
|
|
|
folderPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), Wrap(UpdateFolderPermissions)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Dashboard
|
|
|
|
|
apiRoute.Group("/dashboards", func(dashboardRoute routing.RouteRegister) { |
|
|
|
|
dashboardRoute.Get("/uid/:uid", wrap(GetDashboard)) |
|
|
|
|
dashboardRoute.Delete("/uid/:uid", wrap(DeleteDashboardByUID)) |
|
|
|
|
dashboardRoute.Get("/uid/:uid", Wrap(GetDashboard)) |
|
|
|
|
dashboardRoute.Delete("/uid/:uid", Wrap(DeleteDashboardByUID)) |
|
|
|
|
|
|
|
|
|
dashboardRoute.Get("/db/:slug", wrap(GetDashboard)) |
|
|
|
|
dashboardRoute.Delete("/db/:slug", wrap(DeleteDashboard)) |
|
|
|
|
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", bind(m.SaveDashboardCommand{}), wrap(PostDashboard)) |
|
|
|
|
dashboardRoute.Get("/home", wrap(GetHomeDashboard)) |
|
|
|
|
dashboardRoute.Post("/db", bind(m.SaveDashboardCommand{}), Wrap(PostDashboard)) |
|
|
|
|
dashboardRoute.Get("/home", Wrap(GetHomeDashboard)) |
|
|
|
|
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 routing.RouteRegister) { |
|
|
|
|
dashIdRoute.Get("/versions", wrap(GetDashboardVersions)) |
|
|
|
|
dashIdRoute.Get("/versions/:id", wrap(GetDashboardVersion)) |
|
|
|
|
dashIdRoute.Post("/restore", bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion)) |
|
|
|
|
dashIdRoute.Get("/versions", Wrap(GetDashboardVersions)) |
|
|
|
|
dashIdRoute.Get("/versions/:id", Wrap(GetDashboardVersion)) |
|
|
|
|
dashIdRoute.Post("/restore", bind(dtos.RestoreDashboardVersionCommand{}), Wrap(RestoreDashboardVersion)) |
|
|
|
|
|
|
|
|
|
dashIdRoute.Group("/permissions", func(dashboardPermissionRoute routing.RouteRegister) { |
|
|
|
|
dashboardPermissionRoute.Get("/", wrap(GetDashboardPermissionList)) |
|
|
|
|
dashboardPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateDashboardPermissions)) |
|
|
|
|
dashboardPermissionRoute.Get("/", Wrap(GetDashboardPermissionList)) |
|
|
|
|
dashboardPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), Wrap(UpdateDashboardPermissions)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Dashboard snapshots
|
|
|
|
|
apiRoute.Group("/dashboard/snapshots", func(dashboardRoute routing.RouteRegister) { |
|
|
|
|
dashboardRoute.Get("/", wrap(SearchDashboardSnapshots)) |
|
|
|
|
dashboardRoute.Get("/", Wrap(SearchDashboardSnapshots)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Playlist
|
|
|
|
|
apiRoute.Group("/playlists", func(playlistRoute routing.RouteRegister) { |
|
|
|
|
playlistRoute.Get("/", wrap(SearchPlaylists)) |
|
|
|
|
playlistRoute.Get("/:id", ValidateOrgPlaylist, wrap(GetPlaylist)) |
|
|
|
|
playlistRoute.Get("/:id/items", ValidateOrgPlaylist, wrap(GetPlaylistItems)) |
|
|
|
|
playlistRoute.Get("/:id/dashboards", ValidateOrgPlaylist, wrap(GetPlaylistDashboards)) |
|
|
|
|
playlistRoute.Delete("/:id", reqEditorRole, ValidateOrgPlaylist, wrap(DeletePlaylist)) |
|
|
|
|
playlistRoute.Put("/:id", reqEditorRole, bind(m.UpdatePlaylistCommand{}), ValidateOrgPlaylist, wrap(UpdatePlaylist)) |
|
|
|
|
playlistRoute.Post("/", reqEditorRole, bind(m.CreatePlaylistCommand{}), wrap(CreatePlaylist)) |
|
|
|
|
playlistRoute.Get("/", Wrap(SearchPlaylists)) |
|
|
|
|
playlistRoute.Get("/:id", ValidateOrgPlaylist, Wrap(GetPlaylist)) |
|
|
|
|
playlistRoute.Get("/:id/items", ValidateOrgPlaylist, Wrap(GetPlaylistItems)) |
|
|
|
|
playlistRoute.Get("/:id/dashboards", ValidateOrgPlaylist, Wrap(GetPlaylistDashboards)) |
|
|
|
|
playlistRoute.Delete("/:id", reqEditorRole, ValidateOrgPlaylist, Wrap(DeletePlaylist)) |
|
|
|
|
playlistRoute.Put("/:id", reqEditorRole, bind(m.UpdatePlaylistCommand{}), ValidateOrgPlaylist, Wrap(UpdatePlaylist)) |
|
|
|
|
playlistRoute.Post("/", reqEditorRole, bind(m.CreatePlaylistCommand{}), Wrap(CreatePlaylist)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Search
|
|
|
|
|
apiRoute.Get("/search/", Search) |
|
|
|
|
|
|
|
|
|
// 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/random-walk", wrap(GetTestDataRandomWalk)) |
|
|
|
|
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/random-walk", Wrap(GetTestDataRandomWalk)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/alerts", func(alertsRoute routing.RouteRegister) { |
|
|
|
|
alertsRoute.Post("/test", bind(dtos.AlertTestCommand{}), wrap(AlertTest)) |
|
|
|
|
alertsRoute.Post("/:alertId/pause", reqEditorRole, bind(dtos.PauseAlertCommand{}), wrap(PauseAlert)) |
|
|
|
|
alertsRoute.Get("/:alertId", ValidateOrgAlert, wrap(GetAlert)) |
|
|
|
|
alertsRoute.Get("/", wrap(GetAlerts)) |
|
|
|
|
alertsRoute.Get("/states-for-dashboard", wrap(GetAlertStatesForDashboard)) |
|
|
|
|
alertsRoute.Post("/test", bind(dtos.AlertTestCommand{}), Wrap(AlertTest)) |
|
|
|
|
alertsRoute.Post("/:alertId/pause", reqEditorRole, bind(dtos.PauseAlertCommand{}), Wrap(PauseAlert)) |
|
|
|
|
alertsRoute.Get("/:alertId", ValidateOrgAlert, Wrap(GetAlert)) |
|
|
|
|
alertsRoute.Get("/", Wrap(GetAlerts)) |
|
|
|
|
alertsRoute.Get("/states-for-dashboard", Wrap(GetAlertStatesForDashboard)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
apiRoute.Get("/alert-notifications", wrap(GetAlertNotifications)) |
|
|
|
|
apiRoute.Get("/alert-notifiers", wrap(GetAlertNotifiers)) |
|
|
|
|
apiRoute.Get("/alert-notifications", Wrap(GetAlertNotifications)) |
|
|
|
|
apiRoute.Get("/alert-notifiers", Wrap(GetAlertNotifiers)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/alert-notifications", func(alertNotifications routing.RouteRegister) { |
|
|
|
|
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.Delete("/:notificationId", wrap(DeleteAlertNotification)) |
|
|
|
|
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.Delete("/:notificationId", Wrap(DeleteAlertNotification)) |
|
|
|
|
}, reqEditorRole) |
|
|
|
|
|
|
|
|
|
apiRoute.Get("/annotations", wrap(GetAnnotations)) |
|
|
|
|
apiRoute.Post("/annotations/mass-delete", reqOrgAdmin, bind(dtos.DeleteAnnotationsCmd{}), wrap(DeleteAnnotations)) |
|
|
|
|
apiRoute.Get("/annotations", Wrap(GetAnnotations)) |
|
|
|
|
apiRoute.Post("/annotations/mass-delete", reqOrgAdmin, bind(dtos.DeleteAnnotationsCmd{}), Wrap(DeleteAnnotations)) |
|
|
|
|
|
|
|
|
|
apiRoute.Group("/annotations", func(annotationsRoute routing.RouteRegister) { |
|
|
|
|
annotationsRoute.Post("/", bind(dtos.PostAnnotationsCmd{}), wrap(PostAnnotation)) |
|
|
|
|
annotationsRoute.Delete("/:annotationId", wrap(DeleteAnnotationByID)) |
|
|
|
|
annotationsRoute.Put("/:annotationId", bind(dtos.UpdateAnnotationsCmd{}), wrap(UpdateAnnotation)) |
|
|
|
|
annotationsRoute.Delete("/region/:regionId", wrap(DeleteAnnotationRegion)) |
|
|
|
|
annotationsRoute.Post("/graphite", reqEditorRole, bind(dtos.PostGraphiteAnnotationsCmd{}), wrap(PostGraphiteAnnotation)) |
|
|
|
|
annotationsRoute.Post("/", bind(dtos.PostAnnotationsCmd{}), Wrap(PostAnnotation)) |
|
|
|
|
annotationsRoute.Delete("/:annotationId", Wrap(DeleteAnnotationByID)) |
|
|
|
|
annotationsRoute.Put("/:annotationId", bind(dtos.UpdateAnnotationsCmd{}), Wrap(UpdateAnnotation)) |
|
|
|
|
annotationsRoute.Delete("/region/:regionId", Wrap(DeleteAnnotationRegion)) |
|
|
|
|
annotationsRoute.Post("/graphite", reqEditorRole, bind(dtos.PostGraphiteAnnotationsCmd{}), Wrap(PostGraphiteAnnotation)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// error test
|
|
|
|
|
r.Get("/metrics/error", wrap(GenerateError)) |
|
|
|
|
r.Get("/metrics/error", Wrap(GenerateError)) |
|
|
|
|
|
|
|
|
|
}, reqSignedIn) |
|
|
|
|
|
|
|
|
@ -367,10 +367,10 @@ func (hs *HTTPServer) registerRoutes() { |
|
|
|
|
adminRoute.Put("/users/:id/password", bind(dtos.AdminUpdateUserPasswordForm{}), AdminUpdateUserPassword) |
|
|
|
|
adminRoute.Put("/users/:id/permissions", bind(dtos.AdminUpdateUserPermissionsForm{}), AdminUpdateUserPermissions) |
|
|
|
|
adminRoute.Delete("/users/:id", AdminDeleteUser) |
|
|
|
|
adminRoute.Get("/users/:id/quotas", wrap(GetUserQuotas)) |
|
|
|
|
adminRoute.Put("/users/:id/quotas/:target", bind(m.UpdateUserQuotaCmd{}), wrap(UpdateUserQuota)) |
|
|
|
|
adminRoute.Get("/users/:id/quotas", Wrap(GetUserQuotas)) |
|
|
|
|
adminRoute.Put("/users/:id/quotas/:target", bind(m.UpdateUserQuotaCmd{}), Wrap(UpdateUserQuota)) |
|
|
|
|
adminRoute.Get("/stats", AdminGetStats) |
|
|
|
|
adminRoute.Post("/pause-all-alerts", bind(dtos.PauseAllAlertsCommand{}), wrap(PauseAllAlerts)) |
|
|
|
|
adminRoute.Post("/pause-all-alerts", bind(dtos.PauseAllAlertsCommand{}), Wrap(PauseAllAlerts)) |
|
|
|
|
}, reqGrafanaAdmin) |
|
|
|
|
|
|
|
|
|
// rendering
|
|
|
|
|