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
c400b5cf
Commit
c400b5cf
authored
Jan 31, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:grafana/grafana
parents
1a9aaa41
3e741315
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
7 deletions
+67
-7
docs/sources/http_api/user.md
+34
-0
pkg/api/api.go
+2
-0
pkg/api/user.go
+30
-6
pkg/services/alerting/notifiers/telegram.go
+1
-1
No files found.
docs/sources/http_api/user.md
View file @
c400b5cf
...
...
@@ -69,6 +69,40 @@ parent = "http_api"
"isGrafanaAdmin": true
}
## Get single user by Username(login) or Email
`GET /api/users/lookup`
**Parameter:** `loginOrEmail`
**Example Request using the email as option**:
GET /api/users/lookup?loginOrEmail=user@mygraf.com HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
**Example Request using the username as option**:
GET /api/users/lookup?loginOrEmail=admin HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
**Example Response**:
HTTP/1.1 200
Content-Type: application/json
{
"email": "user@mygraf.com"
"name": "admin",
"login": "admin",
"theme": "light",
"orgId": 1,
"isGrafanaAdmin": true
}
## User Update
`PUT /api/users/:id`
...
...
pkg/api/api.go
View file @
c400b5cf
...
...
@@ -126,6 +126,8 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/"
,
wrap
(
SearchUsers
))
r
.
Get
(
"/:id"
,
wrap
(
GetUserById
))
r
.
Get
(
"/:id/orgs"
,
wrap
(
GetUserOrgList
))
// query parameters /users/lookup?loginOrEmail=admin@example.com
r
.
Get
(
"/lookup"
,
wrap
(
GetUserByLoginOrEmail
))
r
.
Put
(
"/:id"
,
bind
(
m
.
UpdateUserCommand
{}),
wrap
(
UpdateUser
))
r
.
Post
(
"/:id/using/:orgId"
,
wrap
(
UpdateUserActiveOrg
))
},
reqGrafanaAdmin
)
...
...
pkg/api/user.go
View file @
c400b5cf
...
...
@@ -13,7 +13,7 @@ func GetSignedInUser(c *middleware.Context) Response {
return
getUserUserProfile
(
c
.
UserId
)
}
// GET /api/user/:id
// GET /api/user
s
/:id
func
GetUserById
(
c
*
middleware
.
Context
)
Response
{
return
getUserUserProfile
(
c
.
ParamsInt64
(
":id"
))
}
...
...
@@ -22,12 +22,36 @@ func getUserUserProfile(userId int64) Response {
query
:=
m
.
GetUserProfileQuery
{
UserId
:
userId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
if
err
==
m
.
ErrUserNotFound
{
return
ApiError
(
404
,
m
.
ErrUserNotFound
.
Error
(),
nil
)
}
return
ApiError
(
500
,
"Failed to get user"
,
err
)
}
return
Json
(
200
,
query
.
Result
)
}
// GET /api/users/lookup
func
GetUserByLoginOrEmail
(
c
*
middleware
.
Context
)
Response
{
query
:=
m
.
GetUserByLoginQuery
{
LoginOrEmail
:
c
.
Query
(
"loginOrEmail"
)}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
if
err
==
m
.
ErrUserNotFound
{
return
ApiError
(
404
,
m
.
ErrUserNotFound
.
Error
(),
nil
)
}
return
ApiError
(
500
,
"Failed to get user"
,
err
)
}
user
:=
query
.
Result
result
:=
m
.
UserProfileDTO
{
Name
:
user
.
Name
,
Email
:
user
.
Email
,
Login
:
user
.
Login
,
Theme
:
user
.
Theme
,
IsGrafanaAdmin
:
user
.
IsAdmin
,
OrgId
:
user
.
OrgId
,
}
return
Json
(
200
,
&
result
)
}
// POST /api/user
func
UpdateSignedInUser
(
c
*
middleware
.
Context
,
cmd
m
.
UpdateUserCommand
)
Response
{
if
setting
.
AuthProxyEnabled
{
...
...
@@ -60,7 +84,7 @@ func UpdateUserActiveOrg(c *middleware.Context) Response {
cmd
:=
m
.
SetUsingOrgCommand
{
UserId
:
userId
,
OrgId
:
orgId
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed change active organization"
,
err
)
return
ApiError
(
500
,
"Failed
to
change active organization"
,
err
)
}
return
ApiSuccess
(
"Active organization changed"
)
...
...
@@ -70,12 +94,12 @@ func handleUpdateUser(cmd m.UpdateUserCommand) Response {
if
len
(
cmd
.
Login
)
==
0
{
cmd
.
Login
=
cmd
.
Email
if
len
(
cmd
.
Login
)
==
0
{
return
ApiError
(
400
,
"Validation error, need specify either username or email"
,
nil
)
return
ApiError
(
400
,
"Validation error, need
to
specify either username or email"
,
nil
)
}
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"
f
ailed to update user"
,
err
)
return
ApiError
(
500
,
"
F
ailed to update user"
,
err
)
}
return
ApiSuccess
(
"User updated"
)
...
...
@@ -95,7 +119,7 @@ func getUserOrgList(userId int64) Response {
query
:=
m
.
GetUserOrgListQuery
{
UserId
:
userId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
ApiError
(
500
,
"Faile
to get user organzi
ations"
,
err
)
return
ApiError
(
500
,
"Faile
d to get user organiz
ations"
,
err
)
}
return
Json
(
200
,
query
.
Result
)
...
...
@@ -130,7 +154,7 @@ func UserSetUsingOrg(c *middleware.Context) Response {
cmd
:=
m
.
SetUsingOrgCommand
{
UserId
:
c
.
UserId
,
OrgId
:
orgId
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed change active organization"
,
err
)
return
ApiError
(
500
,
"Failed
to
change active organization"
,
err
)
}
return
ApiSuccess
(
"Active organization changed"
)
...
...
pkg/services/alerting/notifiers/telegram.go
View file @
c400b5cf
...
...
@@ -20,7 +20,7 @@ func init() {
Type
:
"telegram"
,
Name
:
"Telegram"
,
Description
:
"Sends notifications to Telegram"
,
Factory
:
New
OpsGenie
Notifier
,
Factory
:
New
Telegram
Notifier
,
OptionsTemplate
:
`
<h3 class="page-heading">Telegram API settings</h3>
<div class="gf-form">
...
...
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