mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #3712 from schen59/master-schen
add get org by name api (issue #3600)
This commit is contained in:
commit
8cf7fb7f80
@ -147,6 +147,11 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Put("/quotas/:target", bind(m.UpdateOrgQuotaCmd{}), wrap(UpdateOrgQuota))
|
r.Put("/quotas/:target", bind(m.UpdateOrgQuotaCmd{}), wrap(UpdateOrgQuota))
|
||||||
}, reqGrafanaAdmin)
|
}, reqGrafanaAdmin)
|
||||||
|
|
||||||
|
// orgs (admin routes)
|
||||||
|
r.Group("/orgs/name/:name", func() {
|
||||||
|
r.Get("/", wrap(GetOrgByName))
|
||||||
|
}, reqGrafanaAdmin)
|
||||||
|
|
||||||
// auth api keys
|
// auth api keys
|
||||||
r.Group("/auth/keys", func() {
|
r.Group("/auth/keys", func() {
|
||||||
r.Get("/", wrap(GetApiKeys))
|
r.Get("/", wrap(GetApiKeys))
|
||||||
|
@ -20,6 +20,33 @@ func GetOrgById(c *middleware.Context) Response {
|
|||||||
return getOrgHelper(c.ParamsInt64(":orgId"))
|
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 {
|
func getOrgHelper(orgId int64) Response {
|
||||||
query := m.GetOrgByIdQuery{Id: orgId}
|
query := m.GetOrgByIdQuery{Id: orgId}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user