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.

51 lines
1.3 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. "code.gitea.io/gitea/modules/context"
  7. api "code.gitea.io/gitea/modules/structs"
  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 of 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. // - name: repository
  27. // in: body
  28. // required: true
  29. // schema: { "$ref": "#/definitions/CreateRepoOption" }
  30. // responses:
  31. // "201":
  32. // "$ref": "#/responses/Repository"
  33. // "403":
  34. // "$ref": "#/responses/forbidden"
  35. // "404":
  36. // "$ref": "#/responses/notFound"
  37. // "409":
  38. // "$ref": "#/responses/error"
  39. // "422":
  40. // "$ref": "#/responses/validationError"
  41. owner := user.GetUserByParams(ctx)
  42. if ctx.Written() {
  43. return
  44. }
  45. repo.CreateUserRepo(ctx, owner, form)
  46. }