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
dc427d5a
Commit
dc427d5a
authored
Jan 12, 2016
by
Shaofeng Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add get org by name api
parent
a87b5f75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
pkg/api/api.go
+5
-0
pkg/api/org.go
+27
-0
No files found.
pkg/api/api.go
View file @
dc427d5a
...
...
@@ -147,6 +147,11 @@ func Register(r *macaron.Macaron) {
r
.
Put
(
"/quotas/:target"
,
bind
(
m
.
UpdateOrgQuotaCmd
{}),
wrap
(
UpdateOrgQuota
))
},
reqGrafanaAdmin
)
// orgs (admin routes)
r
.
Group
(
"/orgs/name/:name"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetOrgByName
))
},
reqGrafanaAdmin
)
// auth api keys
r
.
Group
(
"/auth/keys"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetApiKeys
))
...
...
pkg/api/org.go
View file @
dc427d5a
...
...
@@ -20,6 +20,33 @@ func GetOrgById(c *middleware.Context) Response {
return
getOrgHelper
(
c
.
ParamsInt64
(
":orgId"
))
}
// Get /api/orgs/:name
func
GetOrgByName
(
c
*
middleware
.
Context
)
Response
{
query
:=
m
.
GetOrgByNameQuery
{
Name
:
c
.
Params
(
":name"
)}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
if
err
==
m
.
ErrOrgNotFound
{
return
ApiError
(
404
,
"Organization not found"
,
err
)
}
return
ApiError
(
500
,
"Failed to get organization"
,
err
)
}
org
:=
query
.
Result
result
:=
m
.
OrgDetailsDTO
{
Id
:
org
.
Id
,
Name
:
org
.
Name
,
Address
:
m
.
Address
{
Address1
:
org
.
Address1
,
Address2
:
org
.
Address2
,
City
:
org
.
City
,
ZipCode
:
org
.
ZipCode
,
State
:
org
.
State
,
Country
:
org
.
Country
,
},
}
return
Json
(
200
,
&
result
)
}
func
getOrgHelper
(
orgId
int64
)
Response
{
query
:=
m
.
GetOrgByIdQuery
{
Id
:
orgId
}
...
...
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