You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
663 B

  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package org
  5. import (
  6. api "code.gitea.io/sdk/gitea"
  7. "code.gitea.io/gitea/modules/context"
  8. "code.gitea.io/gitea/routers/api/v1/convert"
  9. )
  10. // ListTeams list all the teams of an organization
  11. func ListTeams(ctx *context.APIContext) {
  12. org := ctx.Org.Organization
  13. if err := org.GetTeams(); err != nil {
  14. ctx.Error(500, "GetTeams", err)
  15. return
  16. }
  17. apiTeams := make([]*api.Team, len(org.Teams))
  18. for i := range org.Teams {
  19. apiTeams[i] = convert.ToTeam(org.Teams[i])
  20. }
  21. ctx.JSON(200, apiTeams)
  22. }