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.

43 lines
1.1 KiB

  1. // Copyright 2015 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 admin
  5. import (
  6. api "code.gitea.io/sdk/gitea"
  7. "code.gitea.io/gitea/modules/context"
  8. "code.gitea.io/gitea/routers/api/v1/repo"
  9. "code.gitea.io/gitea/routers/api/v1/user"
  10. )
  11. // CreateRepo api for creating a repository
  12. func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
  13. // swagger:operation POST /admin/users/{username}/repos admin adminCreateRepo
  14. // ---
  15. // summary: Create a repository on behalf a user
  16. // consumes:
  17. // - application/json
  18. // produces:
  19. // - application/json
  20. // parameters:
  21. // - name: username
  22. // in: path
  23. // description: username of the user. This user will own the created repository
  24. // type: string
  25. // required: true
  26. // responses:
  27. // "201":
  28. // "$ref": "#/responses/Repository"
  29. // "403":
  30. // "$ref": "#/responses/forbidden"
  31. // "422":
  32. // "$ref": "#/responses/validationError"
  33. owner := user.GetUserByParams(ctx)
  34. if ctx.Written() {
  35. return
  36. }
  37. repo.CreateUserRepo(ctx, owner, form)
  38. }