Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6286c31d
Commit
6286c31d
authored
Jul 02, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring: making api wrap public
parent
b8724ae0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
138 deletions
+137
-138
build.go
+0
-1
pkg/api/api.go
+136
-136
pkg/api/common.go
+1
-1
No files found.
build.go
View file @
6286c31d
...
...
@@ -465,7 +465,6 @@ func ldflags() string {
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.version=%s"
,
version
))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.commit=%s"
,
getGitSha
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.buildstamp=%d"
,
buildStamp
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.enterprise=%t"
,
enterprise
))
return
b
.
String
()
}
...
...
pkg/api/api.go
View file @
6286c31d
...
...
@@ -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
{}),
w
rap
(
LoginPost
))
r
.
Post
(
"/login"
,
quota
(
"session"
),
bind
(
dtos
.
LoginCommand
{}),
W
rap
(
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"
,
w
rap
(
GetSignUpOptions
))
r
.
Post
(
"/api/user/signup"
,
quota
(
"user"
),
bind
(
dtos
.
SignUpForm
{}),
w
rap
(
SignUp
))
r
.
Post
(
"/api/user/signup/step2"
,
bind
(
dtos
.
SignUpStep2Form
{}),
w
rap
(
SignUpStep2
))
r
.
Get
(
"/api/user/signup/options"
,
W
rap
(
GetSignUpOptions
))
r
.
Post
(
"/api/user/signup"
,
quota
(
"user"
),
bind
(
dtos
.
SignUpForm
{}),
W
rap
(
SignUp
))
r
.
Post
(
"/api/user/signup/step2"
,
bind
(
dtos
.
SignUpStep2Form
{}),
W
rap
(
SignUpStep2
))
// invited
r
.
Get
(
"/api/user/invite/:code"
,
w
rap
(
GetInviteInfoByCode
))
r
.
Post
(
"/api/user/invite/complete"
,
bind
(
dtos
.
CompleteInviteForm
{}),
w
rap
(
CompleteInvite
))
r
.
Get
(
"/api/user/invite/:code"
,
W
rap
(
GetInviteInfoByCode
))
r
.
Post
(
"/api/user/invite/complete"
,
bind
(
dtos
.
CompleteInviteForm
{}),
W
rap
(
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
{}),
w
rap
(
SendResetPasswordEmail
))
r
.
Post
(
"/api/user/password/reset"
,
bind
(
dtos
.
ResetUserPasswordForm
{}),
w
rap
(
ResetPassword
))
r
.
Post
(
"/api/user/password/send-reset-email"
,
bind
(
dtos
.
SendResetPasswordEmailForm
{}),
W
rap
(
SendResetPasswordEmail
))
r
.
Post
(
"/api/user/password/reset"
,
bind
(
dtos
.
ResetUserPasswordForm
{}),
W
rap
(
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"
,
w
rap
(
DeleteDashboardSnapshotByDeleteKey
))
r
.
Delete
(
"/api/snapshots/:key"
,
reqEditorRole
,
w
rap
(
DeleteDashboardSnapshot
))
r
.
Get
(
"/api/snapshots-delete/:deleteKey"
,
W
rap
(
DeleteDashboardSnapshotByDeleteKey
))
r
.
Delete
(
"/api/snapshots/:key"
,
reqEditorRole
,
W
rap
(
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
(
"/"
,
w
rap
(
GetSignedInUser
))
userRoute
.
Put
(
"/"
,
bind
(
m
.
UpdateUserCommand
{}),
w
rap
(
UpdateSignedInUser
))
userRoute
.
Post
(
"/using/:id"
,
w
rap
(
UserSetUsingOrg
))
userRoute
.
Get
(
"/orgs"
,
w
rap
(
GetSignedInUserOrgList
))
userRoute
.
Get
(
"/"
,
W
rap
(
GetSignedInUser
))
userRoute
.
Put
(
"/"
,
bind
(
m
.
UpdateUserCommand
{}),
W
rap
(
UpdateSignedInUser
))
userRoute
.
Post
(
"/using/:id"
,
W
rap
(
UserSetUsingOrg
))
userRoute
.
Get
(
"/orgs"
,
W
rap
(
GetSignedInUserOrgList
))
userRoute
.
Post
(
"/stars/dashboard/:id"
,
w
rap
(
StarDashboard
))
userRoute
.
Delete
(
"/stars/dashboard/:id"
,
w
rap
(
UnstarDashboard
))
userRoute
.
Post
(
"/stars/dashboard/:id"
,
W
rap
(
StarDashboard
))
userRoute
.
Delete
(
"/stars/dashboard/:id"
,
W
rap
(
UnstarDashboard
))
userRoute
.
Put
(
"/password"
,
bind
(
m
.
ChangeUserPasswordCommand
{}),
w
rap
(
ChangeUserPassword
))
userRoute
.
Get
(
"/quotas"
,
w
rap
(
GetUserQuotas
))
userRoute
.
Put
(
"/helpflags/:id"
,
w
rap
(
SetHelpFlag
))
userRoute
.
Put
(
"/password"
,
bind
(
m
.
ChangeUserPasswordCommand
{}),
W
rap
(
ChangeUserPassword
))
userRoute
.
Get
(
"/quotas"
,
W
rap
(
GetUserQuotas
))
userRoute
.
Put
(
"/helpflags/:id"
,
W
rap
(
SetHelpFlag
))
// For dev purpose
userRoute
.
Get
(
"/helpflags/clear"
,
w
rap
(
ClearHelpFlags
))
userRoute
.
Get
(
"/helpflags/clear"
,
W
rap
(
ClearHelpFlags
))
userRoute
.
Get
(
"/preferences"
,
w
rap
(
GetUserPreferences
))
userRoute
.
Put
(
"/preferences"
,
bind
(
dtos
.
UpdatePrefsCmd
{}),
w
rap
(
UpdateUserPreferences
))
userRoute
.
Get
(
"/preferences"
,
W
rap
(
GetUserPreferences
))
userRoute
.
Put
(
"/preferences"
,
bind
(
dtos
.
UpdatePrefsCmd
{}),
W
rap
(
UpdateUserPreferences
))
})
// users (admin permission required)
apiRoute
.
Group
(
"/users"
,
func
(
usersRoute
routing
.
RouteRegister
)
{
usersRoute
.
Get
(
"/"
,
w
rap
(
SearchUsers
))
usersRoute
.
Get
(
"/search"
,
w
rap
(
SearchUsersWithPaging
))
usersRoute
.
Get
(
"/:id"
,
w
rap
(
GetUserByID
))
usersRoute
.
Get
(
"/:id/orgs"
,
w
rap
(
GetUserOrgList
))
usersRoute
.
Get
(
"/"
,
W
rap
(
SearchUsers
))
usersRoute
.
Get
(
"/search"
,
W
rap
(
SearchUsersWithPaging
))
usersRoute
.
Get
(
"/:id"
,
W
rap
(
GetUserByID
))
usersRoute
.
Get
(
"/:id/orgs"
,
W
rap
(
GetUserOrgList
))
// query parameters /users/lookup?loginOrEmail=admin@example.com
usersRoute
.
Get
(
"/lookup"
,
w
rap
(
GetUserByLoginOrEmail
))
usersRoute
.
Put
(
"/:id"
,
bind
(
m
.
UpdateUserCommand
{}),
w
rap
(
UpdateUser
))
usersRoute
.
Post
(
"/:id/using/:orgId"
,
w
rap
(
UpdateUserActiveOrg
))
usersRoute
.
Get
(
"/lookup"
,
W
rap
(
GetUserByLoginOrEmail
))
usersRoute
.
Put
(
"/:id"
,
bind
(
m
.
UpdateUserCommand
{}),
W
rap
(
UpdateUser
))
usersRoute
.
Post
(
"/:id/using/:orgId"
,
W
rap
(
UpdateUserActiveOrg
))
},
reqGrafanaAdmin
)
// team (admin permission required)
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
teamsRoute
.
Post
(
"/"
,
bind
(
m
.
CreateTeamCommand
{}),
w
rap
(
CreateTeam
))
teamsRoute
.
Put
(
"/:teamId"
,
bind
(
m
.
UpdateTeamCommand
{}),
w
rap
(
UpdateTeam
))
teamsRoute
.
Delete
(
"/:teamId"
,
w
rap
(
DeleteTeamByID
))
teamsRoute
.
Get
(
"/:teamId/members"
,
w
rap
(
GetTeamMembers
))
teamsRoute
.
Post
(
"/:teamId/members"
,
bind
(
m
.
AddTeamMemberCommand
{}),
w
rap
(
AddTeamMember
))
teamsRoute
.
Delete
(
"/:teamId/members/:userId"
,
w
rap
(
RemoveTeamMember
))
teamsRoute
.
Post
(
"/"
,
bind
(
m
.
CreateTeamCommand
{}),
W
rap
(
CreateTeam
))
teamsRoute
.
Put
(
"/:teamId"
,
bind
(
m
.
UpdateTeamCommand
{}),
W
rap
(
UpdateTeam
))
teamsRoute
.
Delete
(
"/:teamId"
,
W
rap
(
DeleteTeamByID
))
teamsRoute
.
Get
(
"/:teamId/members"
,
W
rap
(
GetTeamMembers
))
teamsRoute
.
Post
(
"/:teamId/members"
,
bind
(
m
.
AddTeamMemberCommand
{}),
W
rap
(
AddTeamMember
))
teamsRoute
.
Delete
(
"/:teamId/members/:userId"
,
W
rap
(
RemoveTeamMember
))
},
reqOrgAdmin
)
// team without requirement of user to be org admin
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
teamsRoute
.
Get
(
"/:teamId"
,
w
rap
(
GetTeamByID
))
teamsRoute
.
Get
(
"/search"
,
w
rap
(
SearchTeams
))
teamsRoute
.
Get
(
"/:teamId"
,
W
rap
(
GetTeamByID
))
teamsRoute
.
Get
(
"/search"
,
W
rap
(
SearchTeams
))
})
// org information available to all users.
apiRoute
.
Group
(
"/org"
,
func
(
orgRoute
routing
.
RouteRegister
)
{
orgRoute
.
Get
(
"/"
,
w
rap
(
GetOrgCurrent
))
orgRoute
.
Get
(
"/quotas"
,
w
rap
(
GetOrgQuotas
))
orgRoute
.
Get
(
"/"
,
W
rap
(
GetOrgCurrent
))
orgRoute
.
Get
(
"/quotas"
,
W
rap
(
GetOrgQuotas
))
})
// current org
apiRoute
.
Group
(
"/org"
,
func
(
orgRoute
routing
.
RouteRegister
)
{
orgRoute
.
Put
(
"/"
,
bind
(
dtos
.
UpdateOrgForm
{}),
w
rap
(
UpdateOrgCurrent
))
orgRoute
.
Put
(
"/address"
,
bind
(
dtos
.
UpdateOrgAddressForm
{}),
w
rap
(
UpdateOrgAddressCurrent
))
orgRoute
.
Post
(
"/users"
,
quota
(
"user"
),
bind
(
m
.
AddOrgUserCommand
{}),
w
rap
(
AddOrgUserToCurrentOrg
))
orgRoute
.
Patch
(
"/users/:userId"
,
bind
(
m
.
UpdateOrgUserCommand
{}),
w
rap
(
UpdateOrgUserForCurrentOrg
))
orgRoute
.
Delete
(
"/users/:userId"
,
w
rap
(
RemoveOrgUserForCurrentOrg
))
orgRoute
.
Put
(
"/"
,
bind
(
dtos
.
UpdateOrgForm
{}),
W
rap
(
UpdateOrgCurrent
))
orgRoute
.
Put
(
"/address"
,
bind
(
dtos
.
UpdateOrgAddressForm
{}),
W
rap
(
UpdateOrgAddressCurrent
))
orgRoute
.
Post
(
"/users"
,
quota
(
"user"
),
bind
(
m
.
AddOrgUserCommand
{}),
W
rap
(
AddOrgUserToCurrentOrg
))
orgRoute
.
Patch
(
"/users/:userId"
,
bind
(
m
.
UpdateOrgUserCommand
{}),
W
rap
(
UpdateOrgUserForCurrentOrg
))
orgRoute
.
Delete
(
"/users/:userId"
,
W
rap
(
RemoveOrgUserForCurrentOrg
))
// invites
orgRoute
.
Get
(
"/invites"
,
w
rap
(
GetPendingOrgInvites
))
orgRoute
.
Post
(
"/invites"
,
quota
(
"user"
),
bind
(
dtos
.
AddInviteForm
{}),
w
rap
(
AddOrgInvite
))
orgRoute
.
Patch
(
"/invites/:code/revoke"
,
w
rap
(
RevokeInvite
))
orgRoute
.
Get
(
"/invites"
,
W
rap
(
GetPendingOrgInvites
))
orgRoute
.
Post
(
"/invites"
,
quota
(
"user"
),
bind
(
dtos
.
AddInviteForm
{}),
W
rap
(
AddOrgInvite
))
orgRoute
.
Patch
(
"/invites/:code/revoke"
,
W
rap
(
RevokeInvite
))
// prefs
orgRoute
.
Get
(
"/preferences"
,
w
rap
(
GetOrgPreferences
))
orgRoute
.
Put
(
"/preferences"
,
bind
(
dtos
.
UpdatePrefsCmd
{}),
w
rap
(
UpdateOrgPreferences
))
orgRoute
.
Get
(
"/preferences"
,
W
rap
(
GetOrgPreferences
))
orgRoute
.
Put
(
"/preferences"
,
bind
(
dtos
.
UpdatePrefsCmd
{}),
W
rap
(
UpdateOrgPreferences
))
},
reqOrgAdmin
)
// current org without requirement of user to be org admin
apiRoute
.
Group
(
"/org"
,
func
(
orgRoute
routing
.
RouteRegister
)
{
orgRoute
.
Get
(
"/users"
,
w
rap
(
GetOrgUsersForCurrentOrg
))
orgRoute
.
Get
(
"/users"
,
W
rap
(
GetOrgUsersForCurrentOrg
))
})
// create new org
apiRoute
.
Post
(
"/orgs"
,
quota
(
"org"
),
bind
(
m
.
CreateOrgCommand
{}),
w
rap
(
CreateOrg
))
apiRoute
.
Post
(
"/orgs"
,
quota
(
"org"
),
bind
(
m
.
CreateOrgCommand
{}),
W
rap
(
CreateOrg
))
// search all orgs
apiRoute
.
Get
(
"/orgs"
,
reqGrafanaAdmin
,
w
rap
(
SearchOrgs
))
apiRoute
.
Get
(
"/orgs"
,
reqGrafanaAdmin
,
W
rap
(
SearchOrgs
))
// orgs (admin routes)
apiRoute
.
Group
(
"/orgs/:orgId"
,
func
(
orgsRoute
routing
.
RouteRegister
)
{
orgsRoute
.
Get
(
"/"
,
w
rap
(
GetOrgByID
))
orgsRoute
.
Put
(
"/"
,
bind
(
dtos
.
UpdateOrgForm
{}),
w
rap
(
UpdateOrg
))
orgsRoute
.
Put
(
"/address"
,
bind
(
dtos
.
UpdateOrgAddressForm
{}),
w
rap
(
UpdateOrgAddress
))
orgsRoute
.
Delete
(
"/"
,
w
rap
(
DeleteOrgByID
))
orgsRoute
.
Get
(
"/users"
,
w
rap
(
GetOrgUsers
))
orgsRoute
.
Post
(
"/users"
,
bind
(
m
.
AddOrgUserCommand
{}),
w
rap
(
AddOrgUser
))
orgsRoute
.
Patch
(
"/users/:userId"
,
bind
(
m
.
UpdateOrgUserCommand
{}),
w
rap
(
UpdateOrgUser
))
orgsRoute
.
Delete
(
"/users/:userId"
,
w
rap
(
RemoveOrgUser
))
orgsRoute
.
Get
(
"/quotas"
,
w
rap
(
GetOrgQuotas
))
orgsRoute
.
Put
(
"/quotas/:target"
,
bind
(
m
.
UpdateOrgQuotaCmd
{}),
w
rap
(
UpdateOrgQuota
))
orgsRoute
.
Get
(
"/"
,
W
rap
(
GetOrgByID
))
orgsRoute
.
Put
(
"/"
,
bind
(
dtos
.
UpdateOrgForm
{}),
W
rap
(
UpdateOrg
))
orgsRoute
.
Put
(
"/address"
,
bind
(
dtos
.
UpdateOrgAddressForm
{}),
W
rap
(
UpdateOrgAddress
))
orgsRoute
.
Delete
(
"/"
,
W
rap
(
DeleteOrgByID
))
orgsRoute
.
Get
(
"/users"
,
W
rap
(
GetOrgUsers
))
orgsRoute
.
Post
(
"/users"
,
bind
(
m
.
AddOrgUserCommand
{}),
W
rap
(
AddOrgUser
))
orgsRoute
.
Patch
(
"/users/:userId"
,
bind
(
m
.
UpdateOrgUserCommand
{}),
W
rap
(
UpdateOrgUser
))
orgsRoute
.
Delete
(
"/users/:userId"
,
W
rap
(
RemoveOrgUser
))
orgsRoute
.
Get
(
"/quotas"
,
W
rap
(
GetOrgQuotas
))
orgsRoute
.
Put
(
"/quotas/:target"
,
bind
(
m
.
UpdateOrgQuotaCmd
{}),
W
rap
(
UpdateOrgQuota
))
},
reqGrafanaAdmin
)
// orgs (admin routes)
apiRoute
.
Group
(
"/orgs/name/:name"
,
func
(
orgsRoute
routing
.
RouteRegister
)
{
orgsRoute
.
Get
(
"/"
,
w
rap
(
GetOrgByName
))
orgsRoute
.
Get
(
"/"
,
W
rap
(
GetOrgByName
))
},
reqGrafanaAdmin
)
// auth api keys
apiRoute
.
Group
(
"/auth/keys"
,
func
(
keysRoute
routing
.
RouteRegister
)
{
keysRoute
.
Get
(
"/"
,
w
rap
(
GetAPIKeys
))
keysRoute
.
Post
(
"/"
,
quota
(
"api_key"
),
bind
(
m
.
AddApiKeyCommand
{}),
w
rap
(
AddAPIKey
))
keysRoute
.
Delete
(
"/:id"
,
w
rap
(
DeleteAPIKey
))
keysRoute
.
Get
(
"/"
,
W
rap
(
GetAPIKeys
))
keysRoute
.
Post
(
"/"
,
quota
(
"api_key"
),
bind
(
m
.
AddApiKeyCommand
{}),
W
rap
(
AddAPIKey
))
keysRoute
.
Delete
(
"/:id"
,
W
rap
(
DeleteAPIKey
))
},
reqOrgAdmin
)
// Preferences
apiRoute
.
Group
(
"/preferences"
,
func
(
prefRoute
routing
.
RouteRegister
)
{
prefRoute
.
Post
(
"/set-home-dash"
,
bind
(
m
.
SavePreferencesCommand
{}),
w
rap
(
SetHomeDashboard
))
prefRoute
.
Post
(
"/set-home-dash"
,
bind
(
m
.
SavePreferencesCommand
{}),
W
rap
(
SetHomeDashboard
))
})
// Data sources
apiRoute
.
Group
(
"/datasources"
,
func
(
datasourceRoute
routing
.
RouteRegister
)
{
datasourceRoute
.
Get
(
"/"
,
w
rap
(
GetDataSources
))
datasourceRoute
.
Post
(
"/"
,
quota
(
"data_source"
),
bind
(
m
.
AddDataSourceCommand
{}),
w
rap
(
AddDataSource
))
datasourceRoute
.
Put
(
"/:id"
,
bind
(
m
.
UpdateDataSourceCommand
{}),
w
rap
(
UpdateDataSource
))
datasourceRoute
.
Delete
(
"/:id"
,
w
rap
(
DeleteDataSourceByID
))
datasourceRoute
.
Delete
(
"/name/:name"
,
w
rap
(
DeleteDataSourceByName
))
datasourceRoute
.
Get
(
"/:id"
,
w
rap
(
GetDataSourceByID
))
datasourceRoute
.
Get
(
"/name/:name"
,
w
rap
(
GetDataSourceByName
))
datasourceRoute
.
Get
(
"/"
,
W
rap
(
GetDataSources
))
datasourceRoute
.
Post
(
"/"
,
quota
(
"data_source"
),
bind
(
m
.
AddDataSourceCommand
{}),
W
rap
(
AddDataSource
))
datasourceRoute
.
Put
(
"/:id"
,
bind
(
m
.
UpdateDataSourceCommand
{}),
W
rap
(
UpdateDataSource
))
datasourceRoute
.
Delete
(
"/:id"
,
W
rap
(
DeleteDataSourceByID
))
datasourceRoute
.
Delete
(
"/name/:name"
,
W
rap
(
DeleteDataSourceByName
))
datasourceRoute
.
Get
(
"/:id"
,
W
rap
(
GetDataSourceByID
))
datasourceRoute
.
Get
(
"/name/:name"
,
W
rap
(
GetDataSourceByName
))
},
reqOrgAdmin
)
apiRoute
.
Get
(
"/datasources/id/:name"
,
w
rap
(
GetDataSourceIDByName
),
reqSignedIn
)
apiRoute
.
Get
(
"/datasources/id/:name"
,
W
rap
(
GetDataSourceIDByName
),
reqSignedIn
)
apiRoute
.
Get
(
"/plugins"
,
w
rap
(
GetPluginList
))
apiRoute
.
Get
(
"/plugins/:pluginId/settings"
,
w
rap
(
GetPluginSettingByID
))
apiRoute
.
Get
(
"/plugins/:pluginId/markdown/:name"
,
w
rap
(
GetPluginMarkdown
))
apiRoute
.
Get
(
"/plugins"
,
W
rap
(
GetPluginList
))
apiRoute
.
Get
(
"/plugins/:pluginId/settings"
,
W
rap
(
GetPluginSettingByID
))
apiRoute
.
Get
(
"/plugins/:pluginId/markdown/:name"
,
W
rap
(
GetPluginMarkdown
))
apiRoute
.
Group
(
"/plugins"
,
func
(
pluginRoute
routing
.
RouteRegister
)
{
pluginRoute
.
Get
(
"/:pluginId/dashboards/"
,
w
rap
(
GetPluginDashboards
))
pluginRoute
.
Post
(
"/:pluginId/settings"
,
bind
(
m
.
UpdatePluginSettingCmd
{}),
w
rap
(
UpdatePluginSetting
))
pluginRoute
.
Get
(
"/:pluginId/dashboards/"
,
W
rap
(
GetPluginDashboards
))
pluginRoute
.
Post
(
"/:pluginId/settings"
,
bind
(
m
.
UpdatePluginSettingCmd
{}),
W
rap
(
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
(
"/"
,
w
rap
(
GetFolders
))
folderRoute
.
Get
(
"/id/:id"
,
w
rap
(
GetFolderByID
))
folderRoute
.
Post
(
"/"
,
bind
(
m
.
CreateFolderCommand
{}),
w
rap
(
CreateFolder
))
folderRoute
.
Get
(
"/"
,
W
rap
(
GetFolders
))
folderRoute
.
Get
(
"/id/:id"
,
W
rap
(
GetFolderByID
))
folderRoute
.
Post
(
"/"
,
bind
(
m
.
CreateFolderCommand
{}),
W
rap
(
CreateFolder
))
folderRoute
.
Group
(
"/:uid"
,
func
(
folderUidRoute
routing
.
RouteRegister
)
{
folderUidRoute
.
Get
(
"/"
,
w
rap
(
GetFolderByUID
))
folderUidRoute
.
Put
(
"/"
,
bind
(
m
.
UpdateFolderCommand
{}),
w
rap
(
UpdateFolder
))
folderUidRoute
.
Delete
(
"/"
,
w
rap
(
DeleteFolder
))
folderUidRoute
.
Get
(
"/"
,
W
rap
(
GetFolderByUID
))
folderUidRoute
.
Put
(
"/"
,
bind
(
m
.
UpdateFolderCommand
{}),
W
rap
(
UpdateFolder
))
folderUidRoute
.
Delete
(
"/"
,
W
rap
(
DeleteFolder
))
folderUidRoute
.
Group
(
"/permissions"
,
func
(
folderPermissionRoute
routing
.
RouteRegister
)
{
folderPermissionRoute
.
Get
(
"/"
,
w
rap
(
GetFolderPermissionList
))
folderPermissionRoute
.
Post
(
"/"
,
bind
(
dtos
.
UpdateDashboardAclCommand
{}),
w
rap
(
UpdateFolderPermissions
))
folderPermissionRoute
.
Get
(
"/"
,
W
rap
(
GetFolderPermissionList
))
folderPermissionRoute
.
Post
(
"/"
,
bind
(
dtos
.
UpdateDashboardAclCommand
{}),
W
rap
(
UpdateFolderPermissions
))
})
})
})
// Dashboard
apiRoute
.
Group
(
"/dashboards"
,
func
(
dashboardRoute
routing
.
RouteRegister
)
{
dashboardRoute
.
Get
(
"/uid/:uid"
,
w
rap
(
GetDashboard
))
dashboardRoute
.
Delete
(
"/uid/:uid"
,
w
rap
(
DeleteDashboardByUID
))
dashboardRoute
.
Get
(
"/uid/:uid"
,
W
rap
(
GetDashboard
))
dashboardRoute
.
Delete
(
"/uid/:uid"
,
W
rap
(
DeleteDashboardByUID
))
dashboardRoute
.
Get
(
"/db/:slug"
,
w
rap
(
GetDashboard
))
dashboardRoute
.
Delete
(
"/db/:slug"
,
w
rap
(
DeleteDashboard
))
dashboardRoute
.
Get
(
"/db/:slug"
,
W
rap
(
GetDashboard
))
dashboardRoute
.
Delete
(
"/db/:slug"
,
W
rap
(
DeleteDashboard
))
dashboardRoute
.
Post
(
"/calculate-diff"
,
bind
(
dtos
.
CalculateDiffOptions
{}),
w
rap
(
CalculateDashboardDiff
))
dashboardRoute
.
Post
(
"/calculate-diff"
,
bind
(
dtos
.
CalculateDiffOptions
{}),
W
rap
(
CalculateDashboardDiff
))
dashboardRoute
.
Post
(
"/db"
,
bind
(
m
.
SaveDashboardCommand
{}),
w
rap
(
PostDashboard
))
dashboardRoute
.
Get
(
"/home"
,
w
rap
(
GetHomeDashboard
))
dashboardRoute
.
Post
(
"/db"
,
bind
(
m
.
SaveDashboardCommand
{}),
W
rap
(
PostDashboard
))
dashboardRoute
.
Get
(
"/home"
,
W
rap
(
GetHomeDashboard
))
dashboardRoute
.
Get
(
"/tags"
,
GetDashboardTags
)
dashboardRoute
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
w
rap
(
ImportDashboard
))
dashboardRoute
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
W
rap
(
ImportDashboard
))
dashboardRoute
.
Group
(
"/id/:dashboardId"
,
func
(
dashIdRoute
routing
.
RouteRegister
)
{
dashIdRoute
.
Get
(
"/versions"
,
w
rap
(
GetDashboardVersions
))
dashIdRoute
.
Get
(
"/versions/:id"
,
w
rap
(
GetDashboardVersion
))
dashIdRoute
.
Post
(
"/restore"
,
bind
(
dtos
.
RestoreDashboardVersionCommand
{}),
w
rap
(
RestoreDashboardVersion
))
dashIdRoute
.
Get
(
"/versions"
,
W
rap
(
GetDashboardVersions
))
dashIdRoute
.
Get
(
"/versions/:id"
,
W
rap
(
GetDashboardVersion
))
dashIdRoute
.
Post
(
"/restore"
,
bind
(
dtos
.
RestoreDashboardVersionCommand
{}),
W
rap
(
RestoreDashboardVersion
))
dashIdRoute
.
Group
(
"/permissions"
,
func
(
dashboardPermissionRoute
routing
.
RouteRegister
)
{
dashboardPermissionRoute
.
Get
(
"/"
,
w
rap
(
GetDashboardPermissionList
))
dashboardPermissionRoute
.
Post
(
"/"
,
bind
(
dtos
.
UpdateDashboardAclCommand
{}),
w
rap
(
UpdateDashboardPermissions
))
dashboardPermissionRoute
.
Get
(
"/"
,
W
rap
(
GetDashboardPermissionList
))
dashboardPermissionRoute
.
Post
(
"/"
,
bind
(
dtos
.
UpdateDashboardAclCommand
{}),
W
rap
(
UpdateDashboardPermissions
))
})
})
})
// Dashboard snapshots
apiRoute
.
Group
(
"/dashboard/snapshots"
,
func
(
dashboardRoute
routing
.
RouteRegister
)
{
dashboardRoute
.
Get
(
"/"
,
w
rap
(
SearchDashboardSnapshots
))
dashboardRoute
.
Get
(
"/"
,
W
rap
(
SearchDashboardSnapshots
))
})
// Playlist
apiRoute
.
Group
(
"/playlists"
,
func
(
playlistRoute
routing
.
RouteRegister
)
{
playlistRoute
.
Get
(
"/"
,
w
rap
(
SearchPlaylists
))
playlistRoute
.
Get
(
"/:id"
,
ValidateOrgPlaylist
,
w
rap
(
GetPlaylist
))
playlistRoute
.
Get
(
"/:id/items"
,
ValidateOrgPlaylist
,
w
rap
(
GetPlaylistItems
))
playlistRoute
.
Get
(
"/:id/dashboards"
,
ValidateOrgPlaylist
,
w
rap
(
GetPlaylistDashboards
))
playlistRoute
.
Delete
(
"/:id"
,
reqEditorRole
,
ValidateOrgPlaylist
,
w
rap
(
DeletePlaylist
))
playlistRoute
.
Put
(
"/:id"
,
reqEditorRole
,
bind
(
m
.
UpdatePlaylistCommand
{}),
ValidateOrgPlaylist
,
w
rap
(
UpdatePlaylist
))
playlistRoute
.
Post
(
"/"
,
reqEditorRole
,
bind
(
m
.
CreatePlaylistCommand
{}),
w
rap
(
CreatePlaylist
))
playlistRoute
.
Get
(
"/"
,
W
rap
(
SearchPlaylists
))
playlistRoute
.
Get
(
"/:id"
,
ValidateOrgPlaylist
,
W
rap
(
GetPlaylist
))
playlistRoute
.
Get
(
"/:id/items"
,
ValidateOrgPlaylist
,
W
rap
(
GetPlaylistItems
))
playlistRoute
.
Get
(
"/:id/dashboards"
,
ValidateOrgPlaylist
,
W
rap
(
GetPlaylistDashboards
))
playlistRoute
.
Delete
(
"/:id"
,
reqEditorRole
,
ValidateOrgPlaylist
,
W
rap
(
DeletePlaylist
))
playlistRoute
.
Put
(
"/:id"
,
reqEditorRole
,
bind
(
m
.
UpdatePlaylistCommand
{}),
ValidateOrgPlaylist
,
W
rap
(
UpdatePlaylist
))
playlistRoute
.
Post
(
"/"
,
reqEditorRole
,
bind
(
m
.
CreatePlaylistCommand
{}),
W
rap
(
CreatePlaylist
))
})
// Search
apiRoute
.
Get
(
"/search/"
,
Search
)
// metrics
apiRoute
.
Post
(
"/tsdb/query"
,
bind
(
dtos
.
MetricRequest
{}),
w
rap
(
QueryMetrics
))
apiRoute
.
Get
(
"/tsdb/testdata/scenarios"
,
w
rap
(
GetTestDataScenarios
))
apiRoute
.
Get
(
"/tsdb/testdata/gensql"
,
reqGrafanaAdmin
,
w
rap
(
GenerateSQLTestData
))
apiRoute
.
Get
(
"/tsdb/testdata/random-walk"
,
w
rap
(
GetTestDataRandomWalk
))
apiRoute
.
Post
(
"/tsdb/query"
,
bind
(
dtos
.
MetricRequest
{}),
W
rap
(
QueryMetrics
))
apiRoute
.
Get
(
"/tsdb/testdata/scenarios"
,
W
rap
(
GetTestDataScenarios
))
apiRoute
.
Get
(
"/tsdb/testdata/gensql"
,
reqGrafanaAdmin
,
W
rap
(
GenerateSQLTestData
))
apiRoute
.
Get
(
"/tsdb/testdata/random-walk"
,
W
rap
(
GetTestDataRandomWalk
))
apiRoute
.
Group
(
"/alerts"
,
func
(
alertsRoute
routing
.
RouteRegister
)
{
alertsRoute
.
Post
(
"/test"
,
bind
(
dtos
.
AlertTestCommand
{}),
w
rap
(
AlertTest
))
alertsRoute
.
Post
(
"/:alertId/pause"
,
reqEditorRole
,
bind
(
dtos
.
PauseAlertCommand
{}),
w
rap
(
PauseAlert
))
alertsRoute
.
Get
(
"/:alertId"
,
ValidateOrgAlert
,
w
rap
(
GetAlert
))
alertsRoute
.
Get
(
"/"
,
w
rap
(
GetAlerts
))
alertsRoute
.
Get
(
"/states-for-dashboard"
,
w
rap
(
GetAlertStatesForDashboard
))
alertsRoute
.
Post
(
"/test"
,
bind
(
dtos
.
AlertTestCommand
{}),
W
rap
(
AlertTest
))
alertsRoute
.
Post
(
"/:alertId/pause"
,
reqEditorRole
,
bind
(
dtos
.
PauseAlertCommand
{}),
W
rap
(
PauseAlert
))
alertsRoute
.
Get
(
"/:alertId"
,
ValidateOrgAlert
,
W
rap
(
GetAlert
))
alertsRoute
.
Get
(
"/"
,
W
rap
(
GetAlerts
))
alertsRoute
.
Get
(
"/states-for-dashboard"
,
W
rap
(
GetAlertStatesForDashboard
))
})
apiRoute
.
Get
(
"/alert-notifications"
,
w
rap
(
GetAlertNotifications
))
apiRoute
.
Get
(
"/alert-notifiers"
,
w
rap
(
GetAlertNotifiers
))
apiRoute
.
Get
(
"/alert-notifications"
,
W
rap
(
GetAlertNotifications
))
apiRoute
.
Get
(
"/alert-notifiers"
,
W
rap
(
GetAlertNotifiers
))
apiRoute
.
Group
(
"/alert-notifications"
,
func
(
alertNotifications
routing
.
RouteRegister
)
{
alertNotifications
.
Post
(
"/test"
,
bind
(
dtos
.
NotificationTestCommand
{}),
w
rap
(
NotificationTest
))
alertNotifications
.
Post
(
"/"
,
bind
(
m
.
CreateAlertNotificationCommand
{}),
w
rap
(
CreateAlertNotification
))
alertNotifications
.
Put
(
"/:notificationId"
,
bind
(
m
.
UpdateAlertNotificationCommand
{}),
w
rap
(
UpdateAlertNotification
))
alertNotifications
.
Get
(
"/:notificationId"
,
w
rap
(
GetAlertNotificationByID
))
alertNotifications
.
Delete
(
"/:notificationId"
,
w
rap
(
DeleteAlertNotification
))
alertNotifications
.
Post
(
"/test"
,
bind
(
dtos
.
NotificationTestCommand
{}),
W
rap
(
NotificationTest
))
alertNotifications
.
Post
(
"/"
,
bind
(
m
.
CreateAlertNotificationCommand
{}),
W
rap
(
CreateAlertNotification
))
alertNotifications
.
Put
(
"/:notificationId"
,
bind
(
m
.
UpdateAlertNotificationCommand
{}),
W
rap
(
UpdateAlertNotification
))
alertNotifications
.
Get
(
"/:notificationId"
,
W
rap
(
GetAlertNotificationByID
))
alertNotifications
.
Delete
(
"/:notificationId"
,
W
rap
(
DeleteAlertNotification
))
},
reqEditorRole
)
apiRoute
.
Get
(
"/annotations"
,
w
rap
(
GetAnnotations
))
apiRoute
.
Post
(
"/annotations/mass-delete"
,
reqOrgAdmin
,
bind
(
dtos
.
DeleteAnnotationsCmd
{}),
w
rap
(
DeleteAnnotations
))
apiRoute
.
Get
(
"/annotations"
,
W
rap
(
GetAnnotations
))
apiRoute
.
Post
(
"/annotations/mass-delete"
,
reqOrgAdmin
,
bind
(
dtos
.
DeleteAnnotationsCmd
{}),
W
rap
(
DeleteAnnotations
))
apiRoute
.
Group
(
"/annotations"
,
func
(
annotationsRoute
routing
.
RouteRegister
)
{
annotationsRoute
.
Post
(
"/"
,
bind
(
dtos
.
PostAnnotationsCmd
{}),
w
rap
(
PostAnnotation
))
annotationsRoute
.
Delete
(
"/:annotationId"
,
w
rap
(
DeleteAnnotationByID
))
annotationsRoute
.
Put
(
"/:annotationId"
,
bind
(
dtos
.
UpdateAnnotationsCmd
{}),
w
rap
(
UpdateAnnotation
))
annotationsRoute
.
Delete
(
"/region/:regionId"
,
w
rap
(
DeleteAnnotationRegion
))
annotationsRoute
.
Post
(
"/graphite"
,
reqEditorRole
,
bind
(
dtos
.
PostGraphiteAnnotationsCmd
{}),
w
rap
(
PostGraphiteAnnotation
))
annotationsRoute
.
Post
(
"/"
,
bind
(
dtos
.
PostAnnotationsCmd
{}),
W
rap
(
PostAnnotation
))
annotationsRoute
.
Delete
(
"/:annotationId"
,
W
rap
(
DeleteAnnotationByID
))
annotationsRoute
.
Put
(
"/:annotationId"
,
bind
(
dtos
.
UpdateAnnotationsCmd
{}),
W
rap
(
UpdateAnnotation
))
annotationsRoute
.
Delete
(
"/region/:regionId"
,
W
rap
(
DeleteAnnotationRegion
))
annotationsRoute
.
Post
(
"/graphite"
,
reqEditorRole
,
bind
(
dtos
.
PostGraphiteAnnotationsCmd
{}),
W
rap
(
PostGraphiteAnnotation
))
})
// error test
r
.
Get
(
"/metrics/error"
,
w
rap
(
GenerateError
))
r
.
Get
(
"/metrics/error"
,
W
rap
(
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"
,
w
rap
(
GetUserQuotas
))
adminRoute
.
Put
(
"/users/:id/quotas/:target"
,
bind
(
m
.
UpdateUserQuotaCmd
{}),
w
rap
(
UpdateUserQuota
))
adminRoute
.
Get
(
"/users/:id/quotas"
,
W
rap
(
GetUserQuotas
))
adminRoute
.
Put
(
"/users/:id/quotas/:target"
,
bind
(
m
.
UpdateUserQuotaCmd
{}),
W
rap
(
UpdateUserQuota
))
adminRoute
.
Get
(
"/stats"
,
AdminGetStats
)
adminRoute
.
Post
(
"/pause-all-alerts"
,
bind
(
dtos
.
PauseAllAlertsCommand
{}),
w
rap
(
PauseAllAlerts
))
adminRoute
.
Post
(
"/pause-all-alerts"
,
bind
(
dtos
.
PauseAllAlertsCommand
{}),
W
rap
(
PauseAllAlerts
))
},
reqGrafanaAdmin
)
// rendering
...
...
pkg/api/common.go
View file @
6286c31d
...
...
@@ -30,7 +30,7 @@ type NormalResponse struct {
err
error
}
func
w
rap
(
action
interface
{})
macaron
.
Handler
{
func
W
rap
(
action
interface
{})
macaron
.
Handler
{
return
func
(
c
*
m
.
ReqContext
)
{
var
res
Response
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment