diff options
author | Shashvat Kedia <sk261@snu.edu.in> | 2019-01-24 04:00:19 +0530 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-01-23 17:30:19 -0500 |
commit | 1b90692844c1b714d9c03cf7c96e7f62923236c0 (patch) | |
tree | cb9bb22743da0898bb39c718bb3537a9581e8ea5 /routers/api/v1/admin/org.go | |
parent | b9f87376a2de9dd56fb6c374fc786b6aebd1e911 (diff) | |
download | gitea-1b90692844c1b714d9c03cf7c96e7f62923236c0.tar.gz gitea-1b90692844c1b714d9c03cf7c96e7f62923236c0.zip |
New API routes added (#5594)
* New API routes added
* Comments added
* Build fix
* swagger_v1_json.tmpl without new line character
* Typo fix
* Code review changes
* Code review changes
* Add copyright
* Add copyright
* Add copyright
* Update per @lafriks feedback
* Update org.go
* Update user.go
* Update user.go
* make fmt
Diffstat (limited to 'routers/api/v1/admin/org.go')
-rw-r--r-- | routers/api/v1/admin/org.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 406cbb9a31..03263a86dd 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -1,4 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -66,3 +67,31 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { ctx.JSON(201, convert.ToOrganization(org)) } + +//GetAllOrgs API for getting information of all the organizations +func GetAllOrgs(ctx *context.APIContext) { + // swagger:operation GET /admin/orgs admin adminGetAllOrgs + // --- + // summary: List all organizations + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/OrganizationList" + // "403": + // "$ref": "#/responses/forbidden" + users, _, err := models.SearchUsers(&models.SearchUserOptions{ + Type: models.UserTypeOrganization, + OrderBy: models.SearchOrderByAlphabetically, + PageSize: -1, + }) + if err != nil { + ctx.Error(500, "SearchOrganizations", err) + return + } + orgs := make([]*api.Organization, len(users)) + for i := range users { + orgs[i] = convert.ToOrganization(users[i]) + } + ctx.JSON(200, &orgs) +} |