File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,11 @@ func Register(r *macaron.Macaron) {
147
147
r .Put ("/quotas/:target" , bind (m.UpdateOrgQuotaCmd {}), wrap (UpdateOrgQuota ))
148
148
}, reqGrafanaAdmin )
149
149
150
+ // orgs (admin routes)
151
+ r .Group ("/orgs/name/:name" , func () {
152
+ r .Get ("/" , wrap (GetOrgByName ))
153
+ }, reqGrafanaAdmin )
154
+
150
155
// auth api keys
151
156
r .Group ("/auth/keys" , func () {
152
157
r .Get ("/" , wrap (GetApiKeys ))
Original file line number Diff line number Diff line change @@ -20,6 +20,33 @@ func GetOrgById(c *middleware.Context) Response {
20
20
return getOrgHelper (c .ParamsInt64 (":orgId" ))
21
21
}
22
22
23
+ // Get /api/orgs/:name
24
+ func GetOrgByName (c * middleware.Context ) Response {
25
+ query := m.GetOrgByNameQuery {Name : c .Params (":name" )}
26
+ if err := bus .Dispatch (& query ); err != nil {
27
+ if err == m .ErrOrgNotFound {
28
+ return ApiError (404 , "Organization not found" , err )
29
+ }
30
+
31
+ return ApiError (500 , "Failed to get organization" , err )
32
+ }
33
+ org := query .Result
34
+ result := m.OrgDetailsDTO {
35
+ Id : org .Id ,
36
+ Name : org .Name ,
37
+ Address : m.Address {
38
+ Address1 : org .Address1 ,
39
+ Address2 : org .Address2 ,
40
+ City : org .City ,
41
+ ZipCode : org .ZipCode ,
42
+ State : org .State ,
43
+ Country : org .Country ,
44
+ },
45
+ }
46
+
47
+ return Json (200 , & result )
48
+ }
49
+
23
50
func getOrgHelper (orgId int64 ) Response {
24
51
query := m.GetOrgByIdQuery {Id : orgId }
25
52
You can’t perform that action at this time.
0 commit comments