gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package user
  4. import (
  5. "code.gitea.io/gitea/routers/api/v1/shared"
  6. "code.gitea.io/gitea/services/context"
  7. )
  8. // https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
  9. // GetRegistrationToken returns the token to register user runners
  10. func GetRegistrationToken(ctx *context.APIContext) {
  11. // swagger:operation GET /user/actions/runners/registration-token user userGetRunnerRegistrationToken
  12. // ---
  13. // summary: Get an user's actions runner registration token
  14. // produces:
  15. // - application/json
  16. // parameters:
  17. // responses:
  18. // "200":
  19. // "$ref": "#/responses/RegistrationToken"
  20. shared.GetRegistrationToken(ctx, ctx.Doer.ID, 0)
  21. }
  22. // CreateRegistrationToken returns the token to register user runners
  23. func CreateRegistrationToken(ctx *context.APIContext) {
  24. // swagger:operation POST /user/actions/runners/registration-token user userCreateRunnerRegistrationToken
  25. // ---
  26. // summary: Get an user's actions runner registration token
  27. // produces:
  28. // - application/json
  29. // parameters:
  30. // responses:
  31. // "200":
  32. // "$ref": "#/responses/RegistrationToken"
  33. shared.GetRegistrationToken(ctx, ctx.Doer.ID, 0)
  34. }
  35. // ListRunners get user-level runners
  36. func ListRunners(ctx *context.APIContext) {
  37. // swagger:operation GET /user/actions/runners user getUserRunners
  38. // ---
  39. // summary: Get user-level runners
  40. // produces:
  41. // - application/json
  42. // responses:
  43. // "200":
  44. // "$ref": "#/definitions/ActionRunnersResponse"
  45. // "400":
  46. // "$ref": "#/responses/error"
  47. // "404":
  48. // "$ref": "#/responses/notFound"
  49. shared.ListRunners(ctx, ctx.Doer.ID, 0)
  50. }
  51. // GetRunner get an user-level runner
  52. func GetRunner(ctx *context.APIContext) {
  53. // swagger:operation GET /user/actions/runners/{runner_id} user getUserRunner
  54. // ---
  55. // summary: Get an user-level runner
  56. // produces:
  57. // - application/json
  58. // parameters:
  59. // - name: runner_id
  60. // in: path
  61. // description: id of the runner
  62. // type: string
  63. // required: true
  64. // responses:
  65. // "200":
  66. // "$ref": "#/definitions/ActionRunner"
  67. // "400":
  68. // "$ref": "#/responses/error"
  69. // "404":
  70. // "$ref": "#/responses/notFound"
  71. shared.GetRunner(ctx, ctx.Doer.ID, 0, ctx.PathParamInt64("runner_id"))
  72. }
  73. // DeleteRunner delete an user-level runner
  74. func DeleteRunner(ctx *context.APIContext) {
  75. // swagger:operation DELETE /user/actions/runners/{runner_id} user deleteUserRunner
  76. // ---
  77. // summary: Delete an user-level runner
  78. // produces:
  79. // - application/json
  80. // parameters:
  81. // - name: runner_id
  82. // in: path
  83. // description: id of the runner
  84. // type: string
  85. // required: true
  86. // responses:
  87. // "204":
  88. // description: runner has been deleted
  89. // "400":
  90. // "$ref": "#/responses/error"
  91. // "404":
  92. // "$ref": "#/responses/notFound"
  93. shared.DeleteRunner(ctx, ctx.Doer.ID, 0, ctx.PathParamInt64("runner_id"))
  94. }