forked from mirrors/gitea
Update swagger documentation (#2899)
* Update swagger documentation Add docs for missing endpoints Add documentation for request parameters Make parameter naming consistent Fix response documentation * Restore delete comments
This commit is contained in:
parent
4287d100b3
commit
f26f4a7e01
2
Makefile
2
Makefile
@ -89,8 +89,6 @@ generate-swagger:
|
|||||||
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
||||||
fi
|
fi
|
||||||
swagger generate spec -o ./public/swagger.v1.json
|
swagger generate spec -o ./public/swagger.v1.json
|
||||||
$(SED_INPLACE) "s;\".ref\": \"#/definitions/GPGKey\";\"type\": \"object\";g" ./public/swagger.v1.json
|
|
||||||
$(SED_INPLACE) "s;^ \".ref\": \"#/definitions/Repository\"; \"type\": \"object\";g" ./public/swagger.v1.json
|
|
||||||
|
|
||||||
.PHONY: errcheck
|
.PHONY: errcheck
|
||||||
errcheck:
|
errcheck:
|
||||||
|
@ -41,14 +41,17 @@ func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
|
|||||||
|
|
||||||
// MigrateRepoForm form for migrating repository
|
// MigrateRepoForm form for migrating repository
|
||||||
type MigrateRepoForm struct {
|
type MigrateRepoForm struct {
|
||||||
|
// required: true
|
||||||
CloneAddr string `json:"clone_addr" binding:"Required"`
|
CloneAddr string `json:"clone_addr" binding:"Required"`
|
||||||
AuthUsername string `json:"auth_username"`
|
AuthUsername string `json:"auth_username"`
|
||||||
AuthPassword string `json:"auth_password"`
|
AuthPassword string `json:"auth_password"`
|
||||||
UID int64 `json:"uid" binding:"Required"`
|
// required: true
|
||||||
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
UID int64 `json:"uid" binding:"Required"`
|
||||||
Mirror bool `json:"mirror"`
|
// required: true
|
||||||
Private bool `json:"private"`
|
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||||
Description string `json:"description" binding:"MaxSize(255)"`
|
Mirror bool `json:"mirror"`
|
||||||
|
Private bool `json:"private"`
|
||||||
|
Description string `json:"description" binding:"MaxSize(255)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates the fields
|
// Validate validates the fields
|
||||||
|
6787
public/swagger.v1.json
vendored
6787
public/swagger.v1.json
vendored
File diff suppressed because it is too large
Load Diff
@ -15,20 +15,26 @@ import (
|
|||||||
|
|
||||||
// CreateOrg api for create organization
|
// CreateOrg api for create organization
|
||||||
func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
|
func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
|
||||||
// swagger:route POST /admin/users/{username}/orgs admin adminCreateOrg
|
// swagger:operation POST /admin/users/{username}/orgs admin adminCreateOrg
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create an organization
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: username
|
||||||
// 201: Organization
|
// in: path
|
||||||
// 403: forbidden
|
// description: username of the user that will own the created organization
|
||||||
// 422: validationError
|
// type: string
|
||||||
// 500: error
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Organization"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -14,20 +14,26 @@ import (
|
|||||||
|
|
||||||
// CreateRepo api for creating a repository
|
// CreateRepo api for creating a repository
|
||||||
func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
|
func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
|
||||||
// swagger:route POST /admin/users/{username}/repos admin adminCreateRepo
|
// swagger:operation POST /admin/users/{username}/repos admin adminCreateRepo
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a repository on behalf a user
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: username
|
||||||
// 201: Repository
|
// in: path
|
||||||
// 403: forbidden
|
// description: username of the user. This user will own the created repository
|
||||||
// 422: validationError
|
// type: string
|
||||||
// 500: error
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
owner := user.GetUserByParams(ctx)
|
owner := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -5,13 +5,12 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "code.gitea.io/sdk/gitea"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/routers/api/v1/user"
|
"code.gitea.io/gitea/routers/api/v1/user"
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, loginName string) {
|
func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, loginName string) {
|
||||||
@ -34,22 +33,27 @@ func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, l
|
|||||||
u.LoginName = loginName
|
u.LoginName = loginName
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateUser api for creating a user
|
// CreateUser create a user
|
||||||
func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
||||||
// swagger:route POST /admin/users admin adminCreateUser
|
// swagger:operation POST /admin/users admin adminCreateUser
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a user
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: body
|
||||||
// 201: User
|
// in: body
|
||||||
// 403: forbidden
|
// schema:
|
||||||
// 422: validationError
|
// "$ref": "#/definitions/CreateUserOption"
|
||||||
// 500: error
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/User"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
u := &models.User{
|
u := &models.User{
|
||||||
Name: form.Username,
|
Name: form.Username,
|
||||||
FullName: form.FullName,
|
FullName: form.FullName,
|
||||||
@ -87,20 +91,30 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
|||||||
|
|
||||||
// EditUser api for modifying a user's information
|
// EditUser api for modifying a user's information
|
||||||
func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
||||||
// swagger:route PATCH /admin/users/{username} admin adminEditUser
|
// swagger:operation PATCH /admin/users/{username} admin adminEditUser
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Edit an existing user
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: username
|
||||||
// 200: User
|
// in: path
|
||||||
// 403: forbidden
|
// description: username of user to edit
|
||||||
// 422: validationError
|
// type: string
|
||||||
// 500: error
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditUserOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/User"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -157,17 +171,24 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
|||||||
|
|
||||||
// DeleteUser api for deleting a user
|
// DeleteUser api for deleting a user
|
||||||
func DeleteUser(ctx *context.APIContext) {
|
func DeleteUser(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /admin/users/{username} admin adminDeleteUser
|
// swagger:operation DELETE /admin/users/{username} admin adminDeleteUser
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Delete a user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: username
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 422: validationError
|
// description: username of user to delete
|
||||||
// 500: error
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -189,20 +210,26 @@ func DeleteUser(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreatePublicKey api for creating a public key to a user
|
// CreatePublicKey api for creating a public key to a user
|
||||||
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||||
// swagger:route POST /admin/users/{username}/keys admin adminCreatePublicKey
|
// swagger:operation POST /admin/users/{username}/keys admin adminCreatePublicKey
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Add a public key on behalf of a user
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: username
|
||||||
// 201: PublicKey
|
// in: path
|
||||||
// 403: forbidden
|
// description: username of the user
|
||||||
// 422: validationError
|
// type: string
|
||||||
// 500: error
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/PublicKey"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -4,11 +4,7 @@
|
|||||||
|
|
||||||
// Package v1 Gitea API.
|
// Package v1 Gitea API.
|
||||||
//
|
//
|
||||||
// This provide API interface to communicate with this Gitea instance.
|
// This documentation describes the Gitea API.
|
||||||
//
|
|
||||||
// Terms Of Service:
|
|
||||||
//
|
|
||||||
// there are no TOS at this moment, use at your own risk we take no responsibility
|
|
||||||
//
|
//
|
||||||
// Schemes: http, https
|
// Schemes: http, https
|
||||||
// BasePath: /api/v1
|
// BasePath: /api/v1
|
||||||
@ -51,11 +47,6 @@ package v1
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-macaron/binding"
|
|
||||||
"gopkg.in/macaron.v1"
|
|
||||||
|
|
||||||
api "code.gitea.io/sdk/gitea"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/auth"
|
"code.gitea.io/gitea/modules/auth"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
@ -63,8 +54,13 @@ import (
|
|||||||
"code.gitea.io/gitea/routers/api/v1/misc"
|
"code.gitea.io/gitea/routers/api/v1/misc"
|
||||||
"code.gitea.io/gitea/routers/api/v1/org"
|
"code.gitea.io/gitea/routers/api/v1/org"
|
||||||
"code.gitea.io/gitea/routers/api/v1/repo"
|
"code.gitea.io/gitea/routers/api/v1/repo"
|
||||||
|
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
|
||||||
"code.gitea.io/gitea/routers/api/v1/user"
|
"code.gitea.io/gitea/routers/api/v1/user"
|
||||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
|
||||||
|
"github.com/go-macaron/binding"
|
||||||
|
"gopkg.in/macaron.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func repoAssignment() macaron.Handler {
|
func repoAssignment() macaron.Handler {
|
||||||
@ -320,7 +316,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
m.Get("", user.GetAuthenticatedUser)
|
m.Get("", user.GetAuthenticatedUser)
|
||||||
m.Combo("/emails").Get(user.ListEmails).
|
m.Combo("/emails").Get(user.ListEmails).
|
||||||
Post(bind(api.CreateEmailOption{}), user.AddEmail).
|
Post(bind(api.CreateEmailOption{}), user.AddEmail).
|
||||||
Delete(bind(api.CreateEmailOption{}), user.DeleteEmail)
|
Delete(bind(api.DeleteEmailOption{}), user.DeleteEmail)
|
||||||
|
|
||||||
m.Get("/followers", user.ListMyFollowers)
|
m.Get("/followers", user.ListMyFollowers)
|
||||||
m.Group("/following", func() {
|
m.Group("/following", func() {
|
||||||
@ -435,7 +431,6 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
m.Combo("").Get(repo.ListTrackedTimes).
|
m.Combo("").Get(repo.ListTrackedTimes).
|
||||||
Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime)
|
Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}, mustEnableIssues)
|
}, mustEnableIssues)
|
||||||
m.Group("/labels", func() {
|
m.Group("/labels", func() {
|
||||||
@ -484,8 +479,8 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
Post(reqToken(), reqRepoWriter(), bind(api.CreateStatusOption{}), repo.NewCommitStatus)
|
Post(reqToken(), reqRepoWriter(), bind(api.CreateStatusOption{}), repo.NewCommitStatus)
|
||||||
})
|
})
|
||||||
m.Group("/commits/:ref", func() {
|
m.Group("/commits/:ref", func() {
|
||||||
m.Get("/status", repo.GetCombinedCommitStatus)
|
m.Get("/status", repo.GetCombinedCommitStatusByRef)
|
||||||
m.Get("/statuses", repo.GetCommitStatuses)
|
m.Get("/statuses", repo.GetCommitStatusesByRef)
|
||||||
})
|
})
|
||||||
}, repoAssignment())
|
}, repoAssignment())
|
||||||
})
|
})
|
||||||
|
@ -15,18 +15,23 @@ import (
|
|||||||
|
|
||||||
// Markdown render markdown document to HTML
|
// Markdown render markdown document to HTML
|
||||||
func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
|
func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
|
||||||
// swagger:route POST /markdown miscellaneous renderMarkdown
|
// swagger:operation POST /markdown miscellaneous renderMarkdown
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Render a markdown document as HTML
|
||||||
// - application/json
|
// parameters:
|
||||||
//
|
// - name: body
|
||||||
// Produces:
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/MarkdownOption"
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
// - text/html
|
// - text/html
|
||||||
//
|
// responses:
|
||||||
// Responses:
|
// "200":
|
||||||
// 200: MarkdownRender
|
// "$ref": "#/responses/MarkdownRender"
|
||||||
// 422: validationError
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
if ctx.HasAPIError() {
|
if ctx.HasAPIError() {
|
||||||
ctx.Error(422, "", ctx.GetErrMsg())
|
ctx.Error(422, "", ctx.GetErrMsg())
|
||||||
return
|
return
|
||||||
@ -53,17 +58,22 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
|
|||||||
|
|
||||||
// MarkdownRaw render raw markdown HTML
|
// MarkdownRaw render raw markdown HTML
|
||||||
func MarkdownRaw(ctx *context.APIContext) {
|
func MarkdownRaw(ctx *context.APIContext) {
|
||||||
// swagger:route POST /markdown/raw miscellaneous renderMarkdownRaw
|
// swagger:operation POST /markdown/raw miscellaneous renderMarkdownRaw
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Render raw markdown as HTML
|
||||||
|
// parameters:
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// type: string
|
||||||
|
// consumes:
|
||||||
// - text/plain
|
// - text/plain
|
||||||
//
|
// produces:
|
||||||
// Produces:
|
|
||||||
// - text/html
|
// - text/html
|
||||||
//
|
// responses:
|
||||||
// Responses:
|
// "200":
|
||||||
// 200: MarkdownRender
|
// "$ref": "#/responses/MarkdownRender"
|
||||||
// 422: validationError
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
body, err := ctx.Req.Body().Bytes()
|
body, err := ctx.Req.Body().Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
|
@ -12,17 +12,13 @@ import (
|
|||||||
|
|
||||||
// Version shows the version of the Gitea server
|
// Version shows the version of the Gitea server
|
||||||
func Version(ctx *context.APIContext) {
|
func Version(ctx *context.APIContext) {
|
||||||
// swagger:route GET /version miscellaneous getVersion
|
// swagger:operation GET /version miscellaneous getVersion
|
||||||
//
|
// ---
|
||||||
// Return Gitea running version.
|
// summary: Returns the version of the Gitea application
|
||||||
//
|
// produces:
|
||||||
// This show current running Gitea application version.
|
// - application/json
|
||||||
//
|
// responses:
|
||||||
// Produces:
|
// "200":
|
||||||
// - application/json
|
// "$ref": "#/responses/ServerVersion"
|
||||||
//
|
|
||||||
// Responses:
|
|
||||||
// 200: ServerVersion
|
|
||||||
|
|
||||||
ctx.JSON(200, &gitea.ServerVersion{Version: setting.AppVer})
|
ctx.JSON(200, &gitea.ServerVersion{Version: setting.AppVer})
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,14 @@ import (
|
|||||||
|
|
||||||
// ListHooks list an organziation's webhooks
|
// ListHooks list an organziation's webhooks
|
||||||
func ListHooks(ctx *context.APIContext) {
|
func ListHooks(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/hooks organization orgListHooks
|
// swagger:operation GET /orgs/{org}/hooks organization orgListHooks
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List an organization's webhooks
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: HookList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/HookList"
|
||||||
|
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
orgHooks, err := models.GetWebhooksByOrgID(org.ID)
|
orgHooks, err := models.GetWebhooksByOrgID(org.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -39,16 +38,14 @@ func ListHooks(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetHook get an organization's hook by id
|
// GetHook get an organization's hook by id
|
||||||
func GetHook(ctx *context.APIContext) {
|
func GetHook(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/hooks/{id} organization orgGetHook
|
// swagger:operation GET /orgs/{org}/hooks/{id} organization orgGetHook
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a hook
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: Hook
|
// "200":
|
||||||
// 404: notFound
|
// "$ref": "#/responses/Hook"
|
||||||
// 500: error
|
|
||||||
|
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
hook, err := utils.GetOrgHook(ctx, org.ID, hookID)
|
hook, err := utils.GetOrgHook(ctx, org.ID, hookID)
|
||||||
@ -60,19 +57,16 @@ func GetHook(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateHook create a hook for an organization
|
// CreateHook create a hook for an organization
|
||||||
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
||||||
// swagger:route POST /orgs/{orgname}/hooks/ organization orgCreateHook
|
// swagger:operation POST /orgs/{org}/hooks/ organization orgCreateHook
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a hook
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// responses:
|
||||||
// Responses:
|
// "201":
|
||||||
// 201: Hook
|
// "$ref": "#/responses/Hook"
|
||||||
// 422: validationError
|
|
||||||
// 500: error
|
|
||||||
|
|
||||||
if !utils.CheckCreateHookOption(ctx, &form) {
|
if !utils.CheckCreateHookOption(ctx, &form) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -81,36 +75,30 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
|||||||
|
|
||||||
// EditHook modify a hook of a repository
|
// EditHook modify a hook of a repository
|
||||||
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
||||||
// swagger:route PATCH /orgs/{orgname}/hooks/{id} organization orgEditHook
|
// swagger:operation PATCH /orgs/{org}/hooks/{id} organization orgEditHook
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Update a hook
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// responses:
|
||||||
// Responses:
|
// "200":
|
||||||
// 200: Hook
|
// "$ref": "#/responses/Hook"
|
||||||
// 422: validationError
|
|
||||||
// 404: notFound
|
|
||||||
// 500: error
|
|
||||||
|
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
utils.EditOrgHook(ctx, &form, hookID)
|
utils.EditOrgHook(ctx, &form, hookID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteHook delete a hook of an organization
|
// DeleteHook delete a hook of an organization
|
||||||
func DeleteHook(ctx *context.APIContext) {
|
func DeleteHook(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /orgs/{orgname}/hooks/{id} organization orgDeleteHook
|
// swagger:operation DELETE /orgs/{org}/hooks/{id} organization orgDeleteHook
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Delete a hook
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 204: empty
|
// "204":
|
||||||
// 404: notFound
|
// "$ref": "#/responses/empty"
|
||||||
// 500: error
|
|
||||||
|
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
|
if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
|
||||||
|
@ -53,45 +53,68 @@ func listMembers(ctx *context.APIContext, publicOnly bool) {
|
|||||||
|
|
||||||
// ListMembers list an organization's members
|
// ListMembers list an organization's members
|
||||||
func ListMembers(ctx *context.APIContext) {
|
func ListMembers(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/members organization orgListMembers
|
// swagger:operation GET /orgs/{org}/members organization orgListMembers
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List an organization's members
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: UserList
|
// - name: org
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
publicOnly := ctx.User == nil || !ctx.Org.Organization.IsOrgMember(ctx.User.ID)
|
publicOnly := ctx.User == nil || !ctx.Org.Organization.IsOrgMember(ctx.User.ID)
|
||||||
listMembers(ctx, publicOnly)
|
listMembers(ctx, publicOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPublicMembers list an organization's public members
|
// ListPublicMembers list an organization's public members
|
||||||
func ListPublicMembers(ctx *context.APIContext) {
|
func ListPublicMembers(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/public_members organization orgListPublicMembers
|
// swagger:operation GET /orgs/{org}/public_members organization orgListPublicMembers
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List an organization's public members
|
||||||
// - application/json
|
// parameters:
|
||||||
//
|
// - name: org
|
||||||
// Responses:
|
// in: path
|
||||||
// 200: UserList
|
// description: name of the organization
|
||||||
// 500: error
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
listMembers(ctx, true)
|
listMembers(ctx, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMember check if a user is a member of an organization
|
// IsMember check if a user is a member of an organization
|
||||||
func IsMember(ctx *context.APIContext) {
|
func IsMember(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/members/{username} organization orgIsMember
|
// swagger:operation GET /orgs/{org}/members/{username} organization orgIsMember
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Check if a user is a member of an organization
|
||||||
// - application/json
|
// parameters:
|
||||||
//
|
// - name: org
|
||||||
// Responses:
|
// in: path
|
||||||
// 204: empty
|
// description: name of the organization
|
||||||
// 302: redirect
|
// type: string
|
||||||
// 404: notFound
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: user is a member
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// description: user is not a member
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
userToCheck := user.GetUserByParams(ctx)
|
userToCheck := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -113,15 +136,29 @@ func IsMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// IsPublicMember check if a user is a public member of an organization
|
// IsPublicMember check if a user is a public member of an organization
|
||||||
func IsPublicMember(ctx *context.APIContext) {
|
func IsPublicMember(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/public_members/{username} organization orgIsPublicMember
|
// swagger:operation GET /orgs/{org}/public_members/{username} organization orgIsPublicMember
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Check if a user is a public member of an organization
|
||||||
// - application/json
|
// parameters:
|
||||||
//
|
// - name: org
|
||||||
// Responses:
|
// in: path
|
||||||
// 204: empty
|
// description: name of the organization
|
||||||
// 404: notFound
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: user is a public member
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// description: user is not a public member
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
userToCheck := user.GetUserByParams(ctx)
|
userToCheck := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -135,16 +172,27 @@ func IsPublicMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// PublicizeMember make a member's membership public
|
// PublicizeMember make a member's membership public
|
||||||
func PublicizeMember(ctx *context.APIContext) {
|
func PublicizeMember(ctx *context.APIContext) {
|
||||||
// swagger:route PUT /orgs/{orgname}/public_members/{username} organization orgPublicizeMember
|
// swagger:operation PUT /orgs/{org}/public_members/{username} organization orgPublicizeMember
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Publicize a user's membership
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: org
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 500: error
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: membership publicized
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
userToPublicize := user.GetUserByParams(ctx)
|
userToPublicize := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -163,16 +211,25 @@ func PublicizeMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ConcealMember make a member's membership not public
|
// ConcealMember make a member's membership not public
|
||||||
func ConcealMember(ctx *context.APIContext) {
|
func ConcealMember(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /orgs/{orgname}/public_members/{username} organization orgConcealMember
|
// swagger:operation DELETE /orgs/{org}/public_members/{username} organization orgConcealMember
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Conceal a user's membership
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: org
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 500: error
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
userToConceal := user.GetUserByParams(ctx)
|
userToConceal := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -191,15 +248,27 @@ func ConcealMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// DeleteMember remove a member from an organization
|
// DeleteMember remove a member from an organization
|
||||||
func DeleteMember(ctx *context.APIContext) {
|
func DeleteMember(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /orgs/{orgname}/members/{username} organization orgDeleteMember
|
// swagger:operation DELETE /orgs/{org}/members/{username} organization orgDeleteMember
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Remove a member from an organization
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: org
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: member removed
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
member := user.GetUserByParams(ctx)
|
member := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -27,14 +27,33 @@ func listUserOrgs(ctx *context.APIContext, u *models.User, all bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListMyOrgs list all my orgs
|
// ListMyOrgs list all my orgs
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
|
|
||||||
func ListMyOrgs(ctx *context.APIContext) {
|
func ListMyOrgs(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /user/orgs organization orgListCurrentUserOrgs
|
||||||
|
// ---
|
||||||
|
// summary: List the current user's organizations
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/OrganizationList"
|
||||||
listUserOrgs(ctx, ctx.User, true)
|
listUserOrgs(ctx, ctx.User, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListUserOrgs list user's orgs
|
// ListUserOrgs list user's orgs
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
|
|
||||||
func ListUserOrgs(ctx *context.APIContext) {
|
func ListUserOrgs(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /user/{username}/orgs organization orgListUserOrgs
|
||||||
|
// ---
|
||||||
|
// summary: List a user's organizations
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/OrganizationList"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -43,14 +62,46 @@ func ListUserOrgs(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get get an organization
|
// Get get an organization
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
|
|
||||||
func Get(ctx *context.APIContext) {
|
func Get(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /orgs/{org} organization orgGet
|
||||||
|
// ---
|
||||||
|
// summary: Get an organization
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Organization"
|
||||||
ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization))
|
ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit change an organization's information
|
// Edit change an organization's information
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
|
|
||||||
func Edit(ctx *context.APIContext, form api.EditOrgOption) {
|
func Edit(ctx *context.APIContext, form api.EditOrgOption) {
|
||||||
|
// swagger:operation PATCH /orgs/{org} organization orgEdit
|
||||||
|
// ---
|
||||||
|
// summary: Edit an organization
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization to edit
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditOrgOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Organization"
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
org.FullName = form.FullName
|
org.FullName = form.FullName
|
||||||
org.Description = form.Description
|
org.Description = form.Description
|
||||||
|
@ -15,6 +15,20 @@ import (
|
|||||||
|
|
||||||
// ListTeams list all the teams of an organization
|
// ListTeams list all the teams of an organization
|
||||||
func ListTeams(ctx *context.APIContext) {
|
func ListTeams(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /orgs/{org}/teams organization orgListTeams
|
||||||
|
// ---
|
||||||
|
// summary: List an organization's teams
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/TeamList"
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
if err := org.GetTeams(); err != nil {
|
if err := org.GetTeams(); err != nil {
|
||||||
ctx.Error(500, "GetTeams", err)
|
ctx.Error(500, "GetTeams", err)
|
||||||
@ -30,11 +44,45 @@ func ListTeams(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetTeam api for get a team
|
// GetTeam api for get a team
|
||||||
func GetTeam(ctx *context.APIContext) {
|
func GetTeam(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /teams/{id} organization orgGetTeam
|
||||||
|
// ---
|
||||||
|
// summary: Get a team
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Team"
|
||||||
ctx.JSON(200, convert.ToTeam(ctx.Org.Team))
|
ctx.JSON(200, convert.ToTeam(ctx.Org.Team))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTeam api for create a team
|
// CreateTeam api for create a team
|
||||||
func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
||||||
|
// swagger:operation POST /orgs/{org}/teams organization orgCreateTeam
|
||||||
|
// ---
|
||||||
|
// summary: Create a team
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateTeamOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Team"
|
||||||
team := &models.Team{
|
team := &models.Team{
|
||||||
OrgID: ctx.Org.Organization.ID,
|
OrgID: ctx.Org.Organization.ID,
|
||||||
Name: form.Name,
|
Name: form.Name,
|
||||||
@ -55,6 +103,26 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
|||||||
|
|
||||||
// EditTeam api for edit a team
|
// EditTeam api for edit a team
|
||||||
func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
||||||
|
// swagger:operation PATCH /teams/{id} organization orgEditTeam
|
||||||
|
// ---
|
||||||
|
// summary: Edit a team
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditTeamOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Team"
|
||||||
team := &models.Team{
|
team := &models.Team{
|
||||||
ID: ctx.Org.Team.ID,
|
ID: ctx.Org.Team.ID,
|
||||||
OrgID: ctx.Org.Team.OrgID,
|
OrgID: ctx.Org.Team.OrgID,
|
||||||
@ -71,6 +139,20 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
|||||||
|
|
||||||
// DeleteTeam api for delete a team
|
// DeleteTeam api for delete a team
|
||||||
func DeleteTeam(ctx *context.APIContext) {
|
func DeleteTeam(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /teams/{id} organization orgDeleteTeam
|
||||||
|
// ---
|
||||||
|
// summary: Delete a team
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: team deleted
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if err := models.DeleteTeam(ctx.Org.Team); err != nil {
|
if err := models.DeleteTeam(ctx.Org.Team); err != nil {
|
||||||
ctx.Error(500, "DeleteTeam", err)
|
ctx.Error(500, "DeleteTeam", err)
|
||||||
return
|
return
|
||||||
@ -80,6 +162,20 @@ func DeleteTeam(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetTeamMembers api for get a team's members
|
// GetTeamMembers api for get a team's members
|
||||||
func GetTeamMembers(ctx *context.APIContext) {
|
func GetTeamMembers(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /teams/{id}/members organization orgListTeamMembers
|
||||||
|
// ---
|
||||||
|
// summary: List a team's members
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
if !models.IsOrganizationMember(ctx.Org.Team.OrgID, ctx.User.ID) {
|
if !models.IsOrganizationMember(ctx.Org.Team.OrgID, ctx.User.ID) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
return
|
return
|
||||||
@ -98,6 +194,25 @@ func GetTeamMembers(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// AddTeamMember api for add a member to a team
|
// AddTeamMember api for add a member to a team
|
||||||
func AddTeamMember(ctx *context.APIContext) {
|
func AddTeamMember(ctx *context.APIContext) {
|
||||||
|
// swagger:operation PUT /teams/{id}/members/{username} organization orgAddTeamMember
|
||||||
|
// ---
|
||||||
|
// summary: Add a team member
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user to add
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -111,6 +226,25 @@ func AddTeamMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// RemoveTeamMember api for remove one member from a team
|
// RemoveTeamMember api for remove one member from a team
|
||||||
func RemoveTeamMember(ctx *context.APIContext) {
|
func RemoveTeamMember(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /teams/{id}/members/{username} organization orgAddTeamMember
|
||||||
|
// ---
|
||||||
|
// summary: Remove a team member
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of the user to remove
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
u := user.GetUserByParams(ctx)
|
u := user.GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -125,6 +259,20 @@ func RemoveTeamMember(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetTeamRepos api for get a team's repos
|
// GetTeamRepos api for get a team's repos
|
||||||
func GetTeamRepos(ctx *context.APIContext) {
|
func GetTeamRepos(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /teams/{id}/repos organization orgListTeamRepos
|
||||||
|
// ---
|
||||||
|
// summary: List a team's repos
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
team := ctx.Org.Team
|
team := ctx.Org.Team
|
||||||
if err := team.GetRepositories(); err != nil {
|
if err := team.GetRepositories(); err != nil {
|
||||||
ctx.Error(500, "GetTeamRepos", err)
|
ctx.Error(500, "GetTeamRepos", err)
|
||||||
@ -157,6 +305,30 @@ func getRepositoryByParams(ctx *context.APIContext) *models.Repository {
|
|||||||
|
|
||||||
// AddTeamRepository api for adding a repository to a team
|
// AddTeamRepository api for adding a repository to a team
|
||||||
func AddTeamRepository(ctx *context.APIContext) {
|
func AddTeamRepository(ctx *context.APIContext) {
|
||||||
|
// swagger:operation PUT /teams/{id}/repos/{org}/{repo} organization orgAddTeamMember
|
||||||
|
// ---
|
||||||
|
// summary: Add a repository to a team
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: organization that owns the repo to add
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to add
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
repo := getRepositoryByParams(ctx)
|
repo := getRepositoryByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -177,6 +349,32 @@ func AddTeamRepository(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// RemoveTeamRepository api for removing a repository from a team
|
// RemoveTeamRepository api for removing a repository from a team
|
||||||
func RemoveTeamRepository(ctx *context.APIContext) {
|
func RemoveTeamRepository(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /teams/{id}/repos/{org}/{repo} organization orgAddTeamMember
|
||||||
|
// ---
|
||||||
|
// summary: Remove a repository from a team
|
||||||
|
// description: This does not delete the repository, it only removes the
|
||||||
|
// repository from the team.
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the team
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: organization that owns the repo to remove
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to remove
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
repo := getRepositoryByParams(ctx)
|
repo := getRepositoryByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -13,8 +13,31 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetBranch get a branch of a repository
|
// GetBranch get a branch of a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
|
||||||
func GetBranch(ctx *context.APIContext) {
|
func GetBranch(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/branches/{branch} repository repoGetBranch
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's branches
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: branch
|
||||||
|
// in: path
|
||||||
|
// description: branch to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Branch"
|
||||||
if ctx.Repo.TreePath != "" {
|
if ctx.Repo.TreePath != "" {
|
||||||
// if TreePath != "", then URL contained extra slashes
|
// if TreePath != "", then URL contained extra slashes
|
||||||
// (i.e. "master/subbranch" instead of "master"), so branch does
|
// (i.e. "master/subbranch" instead of "master"), so branch does
|
||||||
@ -42,8 +65,26 @@ func GetBranch(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBranches list all the branches of a repository
|
// ListBranches list all the branches of a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
|
|
||||||
func ListBranches(ctx *context.APIContext) {
|
func ListBranches(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/branches repository repoListBranches
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's branches
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/BranchList"
|
||||||
branches, err := ctx.Repo.Repository.GetBranches()
|
branches, err := ctx.Repo.Repository.GetBranches()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetBranches", err)
|
ctx.Error(500, "GetBranches", err)
|
||||||
|
@ -13,6 +13,25 @@ import (
|
|||||||
|
|
||||||
// ListCollaborators list a repository's collaborators
|
// ListCollaborators list a repository's collaborators
|
||||||
func ListCollaborators(ctx *context.APIContext) {
|
func ListCollaborators(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/collaborators repository repoListCollaborators
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's collaborators
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Error(403, "", "User does not have push access")
|
ctx.Error(403, "", "User does not have push access")
|
||||||
return
|
return
|
||||||
@ -31,6 +50,32 @@ func ListCollaborators(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// IsCollaborator check if a user is a collaborator of a repository
|
// IsCollaborator check if a user is a collaborator of a repository
|
||||||
func IsCollaborator(ctx *context.APIContext) {
|
func IsCollaborator(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/collaborators/{collaborator} repository repoCheckCollaborator
|
||||||
|
// ---
|
||||||
|
// summary: Check if a user is a collaborator of a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: collaborator
|
||||||
|
// in: path
|
||||||
|
// description: username of the collaborator
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Error(403, "", "User does not have push access")
|
ctx.Error(403, "", "User does not have push access")
|
||||||
return
|
return
|
||||||
@ -56,8 +101,36 @@ func IsCollaborator(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCollaborator add a collaborator of a repository
|
// AddCollaborator add a collaborator to a repository
|
||||||
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
||||||
|
// swagger:operation PUT /repos/{owner}/{repo}/collaborators/{collaborator} repository repoAddCollaborator
|
||||||
|
// ---
|
||||||
|
// summary: Add a collaborator to a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: collaborator
|
||||||
|
// in: path
|
||||||
|
// description: username of the collaborator to add
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/AddCollaboratorOption"
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Error(403, "", "User does not have push access")
|
ctx.Error(403, "", "User does not have push access")
|
||||||
return
|
return
|
||||||
@ -89,6 +162,30 @@ func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
|||||||
|
|
||||||
// DeleteCollaborator delete a collaborator from a repository
|
// DeleteCollaborator delete a collaborator from a repository
|
||||||
func DeleteCollaborator(ctx *context.APIContext) {
|
func DeleteCollaborator(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/collaborators/{collaborator} repository repoDeleteCollaborator
|
||||||
|
// ---
|
||||||
|
// summary: Delete a collaborator from a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: collaborator
|
||||||
|
// in: path
|
||||||
|
// description: username of the collaborator to delete
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Error(403, "", "User does not have push access")
|
ctx.Error(403, "", "User does not have push access")
|
||||||
return
|
return
|
||||||
|
@ -13,8 +13,30 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetRawFile get a file by path on a repository
|
// GetRawFile get a file by path on a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
|
|
||||||
func GetRawFile(ctx *context.APIContext) {
|
func GetRawFile(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/raw/{filepath} repository repoGetRawFile
|
||||||
|
// ---
|
||||||
|
// summary: Get a file from a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: filepath
|
||||||
|
// in: path
|
||||||
|
// description: filepath of the file to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// 200:
|
||||||
if !ctx.Repo.HasAccess() {
|
if !ctx.Repo.HasAccess() {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
return
|
return
|
||||||
@ -40,8 +62,30 @@ func GetRawFile(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetArchive get archive of a repository
|
// GetArchive get archive of a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
|
|
||||||
func GetArchive(ctx *context.APIContext) {
|
func GetArchive(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/archive/{filepath} repository repoGetArchive
|
||||||
|
// ---
|
||||||
|
// summary: Get an archive of a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: archive
|
||||||
|
// in: path
|
||||||
|
// description: archive to download, consisting of a git reference and archive
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// 200:
|
||||||
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
|
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
|
||||||
gitRepo, err := git.OpenRepository(repoPath)
|
gitRepo, err := git.OpenRepository(repoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -55,6 +99,29 @@ func GetArchive(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetEditorconfig get editor config of a repository
|
// GetEditorconfig get editor config of a repository
|
||||||
func GetEditorconfig(ctx *context.APIContext) {
|
func GetEditorconfig(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/editorconfig/{filepath} repository repoGetEditorConfig
|
||||||
|
// ---
|
||||||
|
// summary: Get the EditorConfig definitions of a file in a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: filepath
|
||||||
|
// in: path
|
||||||
|
// description: filepath of file to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// 200:
|
||||||
ec, err := ctx.Repo.GetEditorconfig()
|
ec, err := ctx.Repo.GetEditorconfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if git.IsErrNotExist(err) {
|
if git.IsErrNotExist(err) {
|
||||||
|
@ -14,15 +14,25 @@ import (
|
|||||||
|
|
||||||
// ListForks list a repository's forks
|
// ListForks list a repository's forks
|
||||||
func ListForks(ctx *context.APIContext) {
|
func ListForks(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{owner}/{repo}/forks repository listForks
|
// swagger:operation GET /repos/{owner}/{repo}/forks repository listForks
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List a repository's forks
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: RepositoryList
|
// - name: owner
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
forks, err := ctx.Repo.Repository.GetForks()
|
forks, err := ctx.Repo.Repository.GetForks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetForks", err)
|
ctx.Error(500, "GetForks", err)
|
||||||
@ -42,17 +52,29 @@ func ListForks(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateFork create a fork of a repo
|
// CreateFork create a fork of a repo
|
||||||
func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
|
func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
|
||||||
// swagger:route POST /repos/{owner}/{repo}/forks repository createFork
|
// swagger:operation POST /repos/{owner}/{repo}/forks repository createFork
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Fork a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 202: Repository
|
// - name: owner
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 422: validationError
|
// description: owner of the repo to fork
|
||||||
// 500: error
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to fork
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateForkOption"
|
||||||
|
// responses:
|
||||||
|
// "202":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
var forker *models.User // user/org that will own the fork
|
var forker *models.User // user/org that will own the fork
|
||||||
if form.Organization == nil {
|
if form.Organization == nil {
|
||||||
|
@ -15,15 +15,25 @@ import (
|
|||||||
|
|
||||||
// ListHooks list all hooks of a repository
|
// ListHooks list all hooks of a repository
|
||||||
func ListHooks(ctx *context.APIContext) {
|
func ListHooks(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame}/hooks repository repoListHooks
|
// swagger:operation GET /repos/{owner}/{repo}/hooks repository repoListHooks
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the hooks in a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: HookList
|
// - name: owner
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/HookList"
|
||||||
hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID)
|
hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetWebhooksByRepoID", err)
|
ctx.Error(500, "GetWebhooksByRepoID", err)
|
||||||
@ -39,6 +49,30 @@ func ListHooks(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetHook get a repo's hook by id
|
// GetHook get a repo's hook by id
|
||||||
func GetHook(ctx *context.APIContext) {
|
func GetHook(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/hooks/{id} repository repoGetHook
|
||||||
|
// ---
|
||||||
|
// summary: Get a hook
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the hook to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Hook"
|
||||||
repo := ctx.Repo
|
repo := ctx.Repo
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID)
|
hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID)
|
||||||
@ -50,19 +84,31 @@ func GetHook(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateHook create a hook for a repository
|
// CreateHook create a hook for a repository
|
||||||
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
||||||
// swagger:route POST /repos/{username}/{reponame}/hooks repository repoCreateHook
|
// swagger:operation POST /repos/{owner}/{repo}/hooks repository repoCreateHook
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a hook
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: owner
|
||||||
// 200: Hook
|
// in: path
|
||||||
// 422: validationError
|
// description: owner of the repo
|
||||||
// 500: error
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateHookOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Hook"
|
||||||
if !utils.CheckCreateHookOption(ctx, &form) {
|
if !utils.CheckCreateHookOption(ctx, &form) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -71,32 +117,61 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
|||||||
|
|
||||||
// EditHook modify a hook of a repository
|
// EditHook modify a hook of a repository
|
||||||
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
||||||
// swagger:route PATCH /repos/{username}/{reponame}/hooks/{id} repository repoEditHook
|
// swagger:operation PATCH /repos/{owner}/{repo}/hooks/{id} repository repoEditHook
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Edit a hook in a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: Hook
|
// - name: owner
|
||||||
// 422: validationError
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditHookOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Hook"
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
utils.EditRepoHook(ctx, &form, hookID)
|
utils.EditRepoHook(ctx, &form, hookID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteHook delete a hook of a repository
|
// DeleteHook delete a hook of a repository
|
||||||
func DeleteHook(ctx *context.APIContext) {
|
func DeleteHook(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /repos/{username}/{reponame}/hooks/{id} repository repoDeleteHook
|
// swagger:operation DELETE /repos/{user}/{repo}/hooks/{id} repository repoDeleteHook
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Delete a hook in a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: owner
|
||||||
// 404: notFound
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the hook to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||||
if models.IsErrWebhookNotExist(err) {
|
if models.IsErrWebhookNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
|
@ -18,6 +18,33 @@ import (
|
|||||||
|
|
||||||
// ListIssues list the issues of a repository
|
// ListIssues list the issues of a repository
|
||||||
func ListIssues(ctx *context.APIContext) {
|
func ListIssues(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issues issue issueListIssues
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's issues
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: state
|
||||||
|
// in: query
|
||||||
|
// description: whether issue is open or closed
|
||||||
|
// type: string
|
||||||
|
// - name: page
|
||||||
|
// in: query
|
||||||
|
// description: page number of requested issues
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/IssueList"
|
||||||
var isClosed util.OptionalBool
|
var isClosed util.OptionalBool
|
||||||
switch ctx.Query("state") {
|
switch ctx.Query("state") {
|
||||||
case "closed":
|
case "closed":
|
||||||
@ -50,6 +77,30 @@ func ListIssues(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetIssue get an issue of a repository
|
// GetIssue get an issue of a repository
|
||||||
func GetIssue(ctx *context.APIContext) {
|
func GetIssue(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issues/{id} issue issueGetIssue
|
||||||
|
// ---
|
||||||
|
// summary: Get an issue by id
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the issue to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Issue"
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrIssueNotExist(err) {
|
if models.IsErrIssueNotExist(err) {
|
||||||
@ -64,6 +115,31 @@ func GetIssue(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateIssue create an issue of a repository
|
// CreateIssue create an issue of a repository
|
||||||
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue
|
||||||
|
// ---
|
||||||
|
// summary: Create an issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateIssueOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Issue"
|
||||||
issue := &models.Issue{
|
issue := &models.Issue{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
Title: form.Title,
|
Title: form.Title,
|
||||||
@ -114,6 +190,36 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
|||||||
|
|
||||||
// EditIssue modify an issue of a repository
|
// EditIssue modify an issue of a repository
|
||||||
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/issues/{id} issue issueEditIssue
|
||||||
|
// ---
|
||||||
|
// summary: Edit an issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the issue to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditIssueOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Issue"
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrIssueNotExist(err) {
|
if models.IsErrIssueNotExist(err) {
|
||||||
|
@ -15,6 +15,34 @@ import (
|
|||||||
|
|
||||||
// ListIssueComments list all the comments of an issue
|
// ListIssueComments list all the comments of an issue
|
||||||
func ListIssueComments(ctx *context.APIContext) {
|
func ListIssueComments(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issue/{index}/comments issue issueGetComments
|
||||||
|
// ---
|
||||||
|
// summary: List all comments on an issue
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: string
|
||||||
|
// in: query
|
||||||
|
// description: if provided, only comments updated since the specified time are returned.
|
||||||
|
// type: string
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/CommentList"
|
||||||
var since time.Time
|
var since time.Time
|
||||||
if len(ctx.Query("since")) > 0 {
|
if len(ctx.Query("since")) > 0 {
|
||||||
since, _ = time.Parse(time.RFC3339, ctx.Query("since"))
|
since, _ = time.Parse(time.RFC3339, ctx.Query("since"))
|
||||||
@ -44,8 +72,31 @@ func ListIssueComments(ctx *context.APIContext) {
|
|||||||
ctx.JSON(200, &apiComments)
|
ctx.JSON(200, &apiComments)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoIssueComments returns all issue-comments for an issue
|
// ListRepoIssueComments returns all issue-comments for a repo
|
||||||
func ListRepoIssueComments(ctx *context.APIContext) {
|
func ListRepoIssueComments(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issues/comments issue issueGetRepoComments
|
||||||
|
// ---
|
||||||
|
// summary: List all comments in a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: string
|
||||||
|
// in: query
|
||||||
|
// description: if provided, only comments updated since the provided time are returned.
|
||||||
|
// type: string
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/CommentList"
|
||||||
var since time.Time
|
var since time.Time
|
||||||
if len(ctx.Query("since")) > 0 {
|
if len(ctx.Query("since")) > 0 {
|
||||||
since, _ = time.Parse(time.RFC3339, ctx.Query("since"))
|
since, _ = time.Parse(time.RFC3339, ctx.Query("since"))
|
||||||
@ -70,6 +121,36 @@ func ListRepoIssueComments(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateIssueComment create a comment for an issue
|
// CreateIssueComment create a comment for an issue
|
||||||
func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) {
|
func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/issues/{index}/comments issue issueCreateComment
|
||||||
|
// ---
|
||||||
|
// summary: Add a comment to an issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateIssueOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Comment"
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetIssueByIndex", err)
|
ctx.Error(500, "GetIssueByIndex", err)
|
||||||
@ -87,6 +168,36 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti
|
|||||||
|
|
||||||
// EditIssueComment modify a comment of an issue
|
// EditIssueComment modify a comment of an issue
|
||||||
func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
|
func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/comments/{id} issue issueEditComment
|
||||||
|
// ---
|
||||||
|
// summary: Edit a comment
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the comment to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditIssueCommentOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Comment"
|
||||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrCommentNotExist(err) {
|
if models.IsErrCommentNotExist(err) {
|
||||||
@ -115,6 +226,28 @@ func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption)
|
|||||||
|
|
||||||
// DeleteIssueComment delete a comment from an issue
|
// DeleteIssueComment delete a comment from an issue
|
||||||
func DeleteIssueComment(ctx *context.APIContext) {
|
func DeleteIssueComment(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/comments/{id} issue issueDeleteComment
|
||||||
|
// ---
|
||||||
|
// summary: Delete a comment
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of comment to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrCommentNotExist(err) {
|
if models.IsErrCommentNotExist(err) {
|
||||||
|
@ -13,6 +13,32 @@ import (
|
|||||||
|
|
||||||
// ListIssueLabels list all the labels of an issue
|
// ListIssueLabels list all the labels of an issue
|
||||||
func ListIssueLabels(ctx *context.APIContext) {
|
func ListIssueLabels(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/labels issue issueGetLabels
|
||||||
|
// ---
|
||||||
|
// summary: Get an issue's labels
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/LabelList"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrIssueNotExist(err) {
|
if models.IsErrIssueNotExist(err) {
|
||||||
@ -32,6 +58,36 @@ func ListIssueLabels(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// AddIssueLabels add labels for an issue
|
// AddIssueLabels add labels for an issue
|
||||||
func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/issue/{index}/labels issue issueAddLabel
|
||||||
|
// ---
|
||||||
|
// summary: Add a label to an issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/IssueLabelsOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/LabelList"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -73,6 +129,35 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
|||||||
|
|
||||||
// DeleteIssueLabel delete a label for an issue
|
// DeleteIssueLabel delete a label for an issue
|
||||||
func DeleteIssueLabel(ctx *context.APIContext) {
|
func DeleteIssueLabel(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/issue/{index}/labels/{id} issue issueRemoveLabel
|
||||||
|
// ---
|
||||||
|
// summary: Remove a label from an issue
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to remove
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -108,6 +193,36 @@ func DeleteIssueLabel(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ReplaceIssueLabels replace labels for an issue
|
// ReplaceIssueLabels replace labels for an issue
|
||||||
func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
||||||
|
// swagger:operation PUT /repos/{owner}/{repo}/issue/{index}/labels issue issueReplaceLabels
|
||||||
|
// ---
|
||||||
|
// summary: Replace an issue's labels
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/IssueLabelsOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/LabelList"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -149,6 +264,30 @@ func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
|||||||
|
|
||||||
// ClearIssueLabels delete all the labels for an issue
|
// ClearIssueLabels delete all the labels for an issue
|
||||||
func ClearIssueLabels(ctx *context.APIContext) {
|
func ClearIssueLabels(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/issue/{index}/labels issue issueClearLabels
|
||||||
|
// ---
|
||||||
|
// summary: Remove all labels from an issue
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
|
@ -20,15 +20,30 @@ func trackedTimesToAPIFormat(trackedTimes []*models.TrackedTime) []*api.TrackedT
|
|||||||
|
|
||||||
// ListTrackedTimes list all the tracked times of an issue
|
// ListTrackedTimes list all the tracked times of an issue
|
||||||
func ListTrackedTimes(ctx *context.APIContext) {
|
func ListTrackedTimes(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame}/issues/{issue}/times repository issueTrackedTimes
|
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/times issue issueTrackedTimes
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List an issue's tracked times
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: TrackedTimes
|
// - name: owner
|
||||||
// 404: error
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/TrackedTimeList"
|
||||||
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
||||||
ctx.Error(404, "IsTimetrackerEnabled", "Timetracker is diabled")
|
ctx.Error(404, "IsTimetrackerEnabled", "Timetracker is diabled")
|
||||||
return
|
return
|
||||||
@ -54,17 +69,40 @@ func ListTrackedTimes(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// AddTime adds time manual to the given issue
|
// AddTime adds time manual to the given issue
|
||||||
func AddTime(ctx *context.APIContext, form api.AddTimeOption) {
|
func AddTime(ctx *context.APIContext, form api.AddTimeOption) {
|
||||||
// swagger:route Post /repos/{username}/{reponame}/issues/{issue}/times repository addTime
|
// swagger:operation Post /repos/{owner}/{repo}/issues/{index}/times issue issueAddTime
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Add a tracked time to a issue
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// produces:
|
||||||
// 200: TrackedTime
|
// - application/json
|
||||||
// 400: error
|
// parameters:
|
||||||
// 403: error
|
// - name: owner
|
||||||
// 404: error
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue to add tracked time to
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/AddTimeOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/TrackedTime"
|
||||||
|
// "400":
|
||||||
|
// "$ref": "#/responses/error"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/error"
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrIssueNotExist(err) {
|
if models.IsErrIssueNotExist(err) {
|
||||||
@ -93,16 +131,30 @@ func AddTime(ctx *context.APIContext, form api.AddTimeOption) {
|
|||||||
|
|
||||||
// ListTrackedTimesByUser lists all tracked times of the user
|
// ListTrackedTimesByUser lists all tracked times of the user
|
||||||
func ListTrackedTimesByUser(ctx *context.APIContext) {
|
func ListTrackedTimesByUser(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame}/times/{timetrackingusername} user userTrackedTimes
|
// swagger:operation GET /repos/{owner}/{repo}/times/{tracker} user userTrackedTimes
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List a user's tracked times in a repo
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: TrackedTimes
|
// - name: owner
|
||||||
// 400: error
|
// in: path
|
||||||
// 404: error
|
// description: owner of the repo
|
||||||
// 500: error
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: user
|
||||||
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/TrackedTimeList"
|
||||||
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
||||||
ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"})
|
ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"})
|
||||||
return
|
return
|
||||||
@ -131,17 +183,27 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
|
|||||||
ctx.JSON(200, &apiTrackedTimes)
|
ctx.JSON(200, &apiTrackedTimes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListTrackedTimesByRepository lists all tracked times of the user
|
// ListTrackedTimesByRepository lists all tracked times of the repository
|
||||||
func ListTrackedTimesByRepository(ctx *context.APIContext) {
|
func ListTrackedTimesByRepository(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame}/times repository repoTrackedTimes
|
// swagger:operation GET /repos/{owner}/{repo}/times repository repoTrackedTimes
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List a repo's tracked times
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: TrackedTimes
|
// - name: owner
|
||||||
// 400: error
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/TrackedTimeList"
|
||||||
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
if !ctx.Repo.Repository.IsTimetrackerEnabled() {
|
||||||
ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"})
|
ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"})
|
||||||
return
|
return
|
||||||
@ -158,14 +220,14 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ListMyTrackedTimes lists all tracked times of the current user
|
// ListMyTrackedTimes lists all tracked times of the current user
|
||||||
func ListMyTrackedTimes(ctx *context.APIContext) {
|
func ListMyTrackedTimes(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/times user userTrackedTimes
|
// swagger:operation GET /user/times user userCurrentTrackedTimes
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the current user's tracked times
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: TrackedTimes
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/TrackedTimeList"
|
||||||
trackedTimes, err := models.GetTrackedTimes(models.FindTrackedTimesOptions{UserID: ctx.User.ID})
|
trackedTimes, err := models.GetTrackedTimes(models.FindTrackedTimesOptions{UserID: ctx.User.ID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetTrackedTimesByUser", err)
|
ctx.Error(500, "GetTrackedTimesByUser", err)
|
||||||
|
@ -20,8 +20,26 @@ func composeDeployKeysAPILink(repoPath string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDeployKeys list all the deploy keys of a repository
|
// ListDeployKeys list all the deploy keys of a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys
|
|
||||||
func ListDeployKeys(ctx *context.APIContext) {
|
func ListDeployKeys(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/keys repository repoListKeys
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's keys
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/DeployKeyList"
|
||||||
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "ListDeployKeys", err)
|
ctx.Error(500, "ListDeployKeys", err)
|
||||||
@ -42,8 +60,31 @@ func ListDeployKeys(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDeployKey get a deploy key by id
|
// GetDeployKey get a deploy key by id
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key
|
|
||||||
func GetDeployKey(ctx *context.APIContext) {
|
func GetDeployKey(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/keys/{id} repository repoGetKey
|
||||||
|
// ---
|
||||||
|
// summary: Get a repository's key by id
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the key to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/DeployKey"
|
||||||
key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id"))
|
key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrDeployKeyNotExist(err) {
|
if models.IsErrDeployKeyNotExist(err) {
|
||||||
@ -85,8 +126,32 @@ func HandleAddKeyError(ctx *context.APIContext, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateDeployKey create deploy key for a repository
|
// CreateDeployKey create deploy key for a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key
|
|
||||||
func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/keys repository repoCreateKey
|
||||||
|
// ---
|
||||||
|
// summary: Add a key to a repository
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateKeyOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/DeployKey"
|
||||||
content, err := models.CheckPublicKeyString(form.Key)
|
content, err := models.CheckPublicKeyString(form.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
HandleCheckKeyStringError(ctx, err)
|
HandleCheckKeyStringError(ctx, err)
|
||||||
@ -105,8 +170,29 @@ func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteDeploykey delete deploy key for a repository
|
// DeleteDeploykey delete deploy key for a repository
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
|
||||||
func DeleteDeploykey(ctx *context.APIContext) {
|
func DeleteDeploykey(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/keys/{id} repository repoDeleteKey
|
||||||
|
// ---
|
||||||
|
// summary: Delete a key from a repository
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the key to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||||
if models.IsErrKeyAccessDenied(err) {
|
if models.IsErrKeyAccessDenied(err) {
|
||||||
ctx.Error(403, "", "You do not have access to this key")
|
ctx.Error(403, "", "You do not have access to this key")
|
||||||
|
@ -15,6 +15,25 @@ import (
|
|||||||
|
|
||||||
// ListLabels list all the labels of a repository
|
// ListLabels list all the labels of a repository
|
||||||
func ListLabels(ctx *context.APIContext) {
|
func ListLabels(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/labels issue issueListLabels
|
||||||
|
// ---
|
||||||
|
// summary: Get all of a repository's labels
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/LabelList"
|
||||||
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
|
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetLabelsByRepoID", err)
|
ctx.Error(500, "GetLabelsByRepoID", err)
|
||||||
@ -30,6 +49,30 @@ func ListLabels(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetLabel get label by repository and label id
|
// GetLabel get label by repository and label id
|
||||||
func GetLabel(ctx *context.APIContext) {
|
func GetLabel(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/labels/{id} issue issueGetLabel
|
||||||
|
// ---
|
||||||
|
// summary: Get a single label
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
var (
|
var (
|
||||||
label *models.Label
|
label *models.Label
|
||||||
err error
|
err error
|
||||||
@ -54,6 +97,31 @@ func GetLabel(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateLabel create a label for a repository
|
// CreateLabel create a label for a repository
|
||||||
func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
|
func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/labels issue issueCreateLabel
|
||||||
|
// ---
|
||||||
|
// summary: Create a label
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateLabelOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -73,6 +141,36 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
|
|||||||
|
|
||||||
// EditLabel modify a label for a repository
|
// EditLabel modify a label for a repository
|
||||||
func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
|
func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/labels/{id} issue issueEditLabel
|
||||||
|
// ---
|
||||||
|
// summary: Update a label
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditLabelOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -103,6 +201,28 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
|
|||||||
|
|
||||||
// DeleteLabel delete a label for a repository
|
// DeleteLabel delete a label for a repository
|
||||||
func DeleteLabel(ctx *context.APIContext) {
|
func DeleteLabel(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/labels/{id} issue issueDeleteLabel
|
||||||
|
// ---
|
||||||
|
// summary: Delete a label
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
|
@ -15,6 +15,14 @@ import (
|
|||||||
|
|
||||||
// ListMilestones list all the milestones for a repository
|
// ListMilestones list all the milestones for a repository
|
||||||
func ListMilestones(ctx *context.APIContext) {
|
func ListMilestones(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/milestones/{id} issue issueGetMilestone
|
||||||
|
// ---
|
||||||
|
// summary: Get a milestone
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Milestone"
|
||||||
milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
|
milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetMilestonesByRepoID", err)
|
ctx.Error(500, "GetMilestonesByRepoID", err)
|
||||||
@ -30,6 +38,41 @@ func ListMilestones(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetMilestone get a milestone for a repository
|
// GetMilestone get a milestone for a repository
|
||||||
func GetMilestone(ctx *context.APIContext) {
|
func GetMilestone(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestones
|
||||||
|
// ---
|
||||||
|
// summary: Get all of a repository's milestones
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the milestone to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/MilestoneList"
|
||||||
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrMilestoneNotExist(err) {
|
if models.IsErrMilestoneNotExist(err) {
|
||||||
@ -44,6 +87,31 @@ func GetMilestone(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateMilestone create a milestone for a repository
|
// CreateMilestone create a milestone for a repository
|
||||||
func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) {
|
func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/milestones issue issueCreateMilestone
|
||||||
|
// ---
|
||||||
|
// summary: Create a milestone
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateMilestoneOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Milestone"
|
||||||
if form.Deadline == nil {
|
if form.Deadline == nil {
|
||||||
defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
|
defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
|
||||||
form.Deadline = &defaultDeadline
|
form.Deadline = &defaultDeadline
|
||||||
@ -65,6 +133,31 @@ func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) {
|
|||||||
|
|
||||||
// EditMilestone modify a milestone for a repository
|
// EditMilestone modify a milestone for a repository
|
||||||
func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/milestones/{id} issue issueEditMilestone
|
||||||
|
// ---
|
||||||
|
// summary: Update a milestone
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditMilestoneOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Milestone"
|
||||||
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrMilestoneNotExist(err) {
|
if models.IsErrMilestoneNotExist(err) {
|
||||||
@ -94,6 +187,28 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
|||||||
|
|
||||||
// DeleteMilestone delete a milestone for a repository
|
// DeleteMilestone delete a milestone for a repository
|
||||||
func DeleteMilestone(ctx *context.APIContext) {
|
func DeleteMilestone(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/milestones/{id} issue issueDeleteMilestone
|
||||||
|
// ---
|
||||||
|
// summary: Delete a milestone
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: path
|
||||||
|
// description: id of the milestone to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||||
ctx.Error(500, "DeleteMilestoneByRepoID", err)
|
ctx.Error(500, "DeleteMilestoneByRepoID", err)
|
||||||
return
|
return
|
||||||
|
@ -18,6 +18,25 @@ import (
|
|||||||
|
|
||||||
// ListPullRequests returns a list of all PRs
|
// ListPullRequests returns a list of all PRs
|
||||||
func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions) {
|
func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/pulls repository repoListPullRequests
|
||||||
|
// ---
|
||||||
|
// summary: List a repo's pull requests
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/PullRequestList"
|
||||||
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
|
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
|
||||||
Page: ctx.QueryInt("page"),
|
Page: ctx.QueryInt("page"),
|
||||||
State: ctx.QueryTrim("state"),
|
State: ctx.QueryTrim("state"),
|
||||||
@ -58,6 +77,30 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
|
|||||||
|
|
||||||
// GetPullRequest returns a single PR based on index
|
// GetPullRequest returns a single PR based on index
|
||||||
func GetPullRequest(ctx *context.APIContext) {
|
func GetPullRequest(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index} repository repoGetPullRequest
|
||||||
|
// ---
|
||||||
|
// summary: Get a pull request
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the pull request to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/PullRequest"
|
||||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrPullRequestNotExist(err) {
|
if models.IsErrPullRequestNotExist(err) {
|
||||||
@ -81,6 +124,31 @@ func GetPullRequest(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreatePullRequest does what it says
|
// CreatePullRequest does what it says
|
||||||
func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption) {
|
func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/pulls repository repoCreatePullRequest
|
||||||
|
// ---
|
||||||
|
// summary: Create a pull request
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreatePullRequestOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/PullRequest"
|
||||||
var (
|
var (
|
||||||
repo = ctx.Repo.Repository
|
repo = ctx.Repo.Repository
|
||||||
labelIDs []int64
|
labelIDs []int64
|
||||||
@ -204,6 +272,36 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
|
|||||||
|
|
||||||
// EditPullRequest does what it says
|
// EditPullRequest does what it says
|
||||||
func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/pulls/{index} repository repoEditPullRequest
|
||||||
|
// ---
|
||||||
|
// summary: Update a pull request
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the pull request to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditPullRequestOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/PullRequest"
|
||||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrPullRequestNotExist(err) {
|
if models.IsErrPullRequestNotExist(err) {
|
||||||
@ -283,13 +381,42 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO this should be 200, not 201
|
||||||
ctx.JSON(201, pr.APIFormat())
|
ctx.JSON(201, pr.APIFormat())
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPullRequestMerged checks if a PR exists given an index
|
// IsPullRequestMerged checks if a PR exists given an index
|
||||||
// - Returns 204 if it exists
|
|
||||||
// Otherwise 404
|
|
||||||
func IsPullRequestMerged(ctx *context.APIContext) {
|
func IsPullRequestMerged(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index}/merge repository repoPullRequestIsMerged
|
||||||
|
// ---
|
||||||
|
// summary: Check if a pull request has been merged
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the pull request
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// description: pull request has been merged
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// description: pull request has not been merged
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrPullRequestNotExist(err) {
|
if models.IsErrPullRequestNotExist(err) {
|
||||||
@ -308,6 +435,32 @@ func IsPullRequestMerged(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// MergePullRequest merges a PR given an index
|
// MergePullRequest merges a PR given an index
|
||||||
func MergePullRequest(ctx *context.APIContext) {
|
func MergePullRequest(ctx *context.APIContext) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/pulls/{index}/merge repository repoMergePullRequest
|
||||||
|
// ---
|
||||||
|
// summary: Merge a pull request
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the pull request to merge
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "405":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrPullRequestNotExist(err) {
|
if models.IsErrPullRequestNotExist(err) {
|
||||||
|
@ -13,6 +13,30 @@ import (
|
|||||||
|
|
||||||
// GetRelease get a single release of a repository
|
// GetRelease get a single release of a repository
|
||||||
func GetRelease(ctx *context.APIContext) {
|
func GetRelease(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/releases repository repoGetRelease
|
||||||
|
// ---
|
||||||
|
// summary: Get a release
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: id of the release to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Release"
|
||||||
id := ctx.ParamsInt64(":id")
|
id := ctx.ParamsInt64(":id")
|
||||||
release, err := models.GetReleaseByID(id)
|
release, err := models.GetReleaseByID(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,6 +56,25 @@ func GetRelease(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ListReleases list a repository's releases
|
// ListReleases list a repository's releases
|
||||||
func ListReleases(ctx *context.APIContext) {
|
func ListReleases(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases
|
||||||
|
// ---
|
||||||
|
// summary: List a repo's releases
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/ReleaseList"
|
||||||
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
|
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
|
||||||
IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite,
|
IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite,
|
||||||
IncludeTags: false,
|
IncludeTags: false,
|
||||||
@ -53,6 +96,31 @@ func ListReleases(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateRelease create a release
|
// CreateRelease create a release
|
||||||
func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
|
func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/releases repository repoCreateRelease
|
||||||
|
// ---
|
||||||
|
// summary: Create a release
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateReleaseOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Release"
|
||||||
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -110,6 +178,36 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
|
|||||||
|
|
||||||
// EditRelease edit a release
|
// EditRelease edit a release
|
||||||
func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) {
|
func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) {
|
||||||
|
// swagger:operation PATCH /repos/{owner}/{repo}/releases/{id} repository repoEditRelease
|
||||||
|
// ---
|
||||||
|
// summary: Update a release
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the release to edit
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditReleaseOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Release"
|
||||||
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
@ -163,6 +261,28 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) {
|
|||||||
|
|
||||||
// DeleteRelease delete a release from a repository
|
// DeleteRelease delete a release from a repository
|
||||||
func DeleteRelease(ctx *context.APIContext) {
|
func DeleteRelease(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/releases/{id} repository repoDeleteRelease
|
||||||
|
// ---
|
||||||
|
// summary: Delete a release
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the release to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
if ctx.Repo.AccessMode < models.AccessModeWrite {
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
return
|
return
|
||||||
|
@ -20,45 +20,40 @@ import (
|
|||||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchRepoOption options when searching repositories
|
|
||||||
// swagger:parameters repoSearch
|
|
||||||
type SearchRepoOption struct { // TODO: Move SearchRepoOption to Gitea SDK
|
|
||||||
// Keyword to search
|
|
||||||
//
|
|
||||||
// in: query
|
|
||||||
Keyword string `json:"q"`
|
|
||||||
// Repository owner to search
|
|
||||||
//
|
|
||||||
// in: query
|
|
||||||
OwnerID int64 `json:"uid"`
|
|
||||||
// Limit of result
|
|
||||||
//
|
|
||||||
// maximum: setting.ExplorePagingNum
|
|
||||||
// in: query
|
|
||||||
PageSize int `json:"limit"`
|
|
||||||
// Type of repository to search, related to owner
|
|
||||||
//
|
|
||||||
// in: query
|
|
||||||
SearchMode string `json:"mode"`
|
|
||||||
// Search only owners repositories
|
|
||||||
// Has effect only if owner is provided and mode is not "collaborative"
|
|
||||||
//
|
|
||||||
// in: query
|
|
||||||
OwnerExclusive bool `json:"exclusive"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search repositories via options
|
// Search repositories via options
|
||||||
func Search(ctx *context.APIContext) {
|
func Search(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/search repository repoSearch
|
// swagger:operation GET /repos/search repository repoSearch
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Search for repositories
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: SearchResults
|
// - name: q
|
||||||
// 422: validationError
|
// in: query
|
||||||
// 500: SearchError
|
// description: keyword
|
||||||
|
// type: string
|
||||||
|
// - name: uid
|
||||||
|
// in: query
|
||||||
|
// description: if provided, will return only repos owned by the user with the given id
|
||||||
|
// type: integer
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: maximum number of repos to return
|
||||||
|
// type: integer
|
||||||
|
// - name: mode
|
||||||
|
// in: query
|
||||||
|
// description: type of repository to search for. Supported values are
|
||||||
|
// "fork", "source", "mirror" and "collaborative"
|
||||||
|
// type: string
|
||||||
|
// - name: exclusive
|
||||||
|
// in: query
|
||||||
|
// description: only search for repositories owned by the authenticated user
|
||||||
|
// type: boolean
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/SearchResults"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
opts := &models.SearchRepoOptions{
|
opts := &models.SearchRepoOptions{
|
||||||
Keyword: strings.Trim(ctx.Query("q"), " "),
|
Keyword: strings.Trim(ctx.Query("q"), " "),
|
||||||
OwnerID: ctx.QueryInt64("uid"),
|
OwnerID: ctx.QueryInt64("uid"),
|
||||||
@ -187,22 +182,23 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
|
|||||||
|
|
||||||
// Create one repository of mine
|
// Create one repository of mine
|
||||||
func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||||
// swagger:route POST /user/repos repository user createCurrentUserRepo
|
// swagger:operation POST /user/repos repository user createCurrentUserRepo
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a repository
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: body
|
||||||
// 201: Repository
|
// in: body
|
||||||
// 403: forbidden
|
// schema:
|
||||||
// 422: validationError
|
// "$ref": "#/definitions/CreateRepoOption"
|
||||||
// 500: error
|
// responses:
|
||||||
|
// "201":
|
||||||
// Shouldn't reach this condition, but just in case.
|
// "$ref": "#/responses/Repository"
|
||||||
if ctx.User.IsOrganization() {
|
if ctx.User.IsOrganization() {
|
||||||
|
// Shouldn't reach this condition, but just in case.
|
||||||
ctx.Error(422, "", "not allowed creating repository for organization")
|
ctx.Error(422, "", "not allowed creating repository for organization")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -211,20 +207,30 @@ func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
|||||||
|
|
||||||
// CreateOrgRepo create one repository of the organization
|
// CreateOrgRepo create one repository of the organization
|
||||||
func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||||
// swagger:route POST /org/{org}/repos organization createOrgRepo
|
// swagger:operation POST /org/{org}/repos organization createOrgRepo
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a repository in an organization
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: org
|
||||||
// 201: Repository
|
// in: path
|
||||||
// 422: validationError
|
// description: name of organization
|
||||||
// 403: forbidden
|
// type: string
|
||||||
// 500: error
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateRepoOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
org, err := models.GetOrgByName(ctx.Params(":org"))
|
org, err := models.GetOrgByName(ctx.Params(":org"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrOrgNotExist(err) {
|
if models.IsErrOrgNotExist(err) {
|
||||||
@ -244,19 +250,21 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
|||||||
|
|
||||||
// Migrate migrate remote git repository to gitea
|
// Migrate migrate remote git repository to gitea
|
||||||
func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
||||||
// swagger:route POST /repos/migrate repository repoMigrate
|
// swagger:operation POST /repos/migrate repository repoMigrate
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Migrate a remote git repository
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: body
|
||||||
// 201: Repository
|
// in: body
|
||||||
// 422: validationError
|
// schema:
|
||||||
// 500: error
|
// "$ref": "#/definitions/MigrateRepoForm"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
ctxUser := ctx.User
|
ctxUser := ctx.User
|
||||||
// Not equal means context user is an organization,
|
// Not equal means context user is an organization,
|
||||||
// or is another user/organization if current user is admin.
|
// or is another user/organization if current user is admin.
|
||||||
@ -329,29 +337,44 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
|||||||
|
|
||||||
// Get one repository
|
// Get one repository
|
||||||
func Get(ctx *context.APIContext) {
|
func Get(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame} repository repoGet
|
// swagger:operation GET /repos/{owner}/{repo} repository repoGet
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: Repository
|
// - name: owner
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
ctx.JSON(200, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode))
|
ctx.JSON(200, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetByID returns a single Repository
|
// GetByID returns a single Repository
|
||||||
func GetByID(ctx *context.APIContext) {
|
func GetByID(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repositories/{id} repository repoGetByID
|
// swagger:operation GET /repositories/{id} repository repoGetByID
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a repository by id
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: Repository
|
// - name: id
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: id of the repo to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Repository"
|
||||||
repo, err := models.GetRepositoryByID(ctx.ParamsInt64(":id"))
|
repo, err := models.GetRepositoryByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrRepoNotExist(err) {
|
if models.IsErrRepoNotExist(err) {
|
||||||
@ -375,16 +398,27 @@ func GetByID(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Delete one repository
|
// Delete one repository
|
||||||
func Delete(ctx *context.APIContext) {
|
func Delete(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /repos/{username}/{reponame} repository repoDelete
|
// swagger:operation DELETE /repos/{owner}/{repo} repository repoDelete
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Delete a repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: owner
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 500: error
|
// description: owner of the repo to delete
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to delete
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
if !ctx.Repo.IsAdmin() {
|
if !ctx.Repo.IsAdmin() {
|
||||||
ctx.Error(403, "", "Must have admin rights")
|
ctx.Error(403, "", "Must have admin rights")
|
||||||
return
|
return
|
||||||
@ -408,15 +442,25 @@ func Delete(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// MirrorSync adds a mirrored repository to the sync queue
|
// MirrorSync adds a mirrored repository to the sync queue
|
||||||
func MirrorSync(ctx *context.APIContext) {
|
func MirrorSync(ctx *context.APIContext) {
|
||||||
// swagger:route POST /repos/{username}/{reponame}/mirror-sync repository repoMirrorSync
|
// swagger:operation POST /repos/{owner}/{repo}/mirror-sync repository repoMirrorSync
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Sync a mirrored repository
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: empty
|
// - name: owner
|
||||||
// 403: forbidden
|
// in: path
|
||||||
|
// description: owner of the repo to sync
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to sync
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
|
||||||
if !ctx.Repo.IsWriter() {
|
if !ctx.Repo.IsWriter() {
|
||||||
|
@ -12,6 +12,25 @@ import (
|
|||||||
|
|
||||||
// ListStargazers list a repository's stargazers
|
// ListStargazers list a repository's stargazers
|
||||||
func ListStargazers(ctx *context.APIContext) {
|
func ListStargazers(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/stargazers repository repoListStargazers
|
||||||
|
// ---
|
||||||
|
// summary: List a repo's stargazers
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
stargazers, err := ctx.Repo.Repository.GetStargazers(-1)
|
stargazers, err := ctx.Repo.Repository.GetStargazers(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetStargazers", err)
|
ctx.Error(500, "GetStargazers", err)
|
||||||
|
@ -14,6 +14,34 @@ import (
|
|||||||
|
|
||||||
// NewCommitStatus creates a new CommitStatus
|
// NewCommitStatus creates a new CommitStatus
|
||||||
func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) {
|
func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) {
|
||||||
|
// swagger:operation POST /repos/{owner}/{repo}/statuses/{sha} repository repoCreateStatus
|
||||||
|
// ---
|
||||||
|
// summary: Create a commit status
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: sha
|
||||||
|
// in: path
|
||||||
|
// description: sha of the commit
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateStatusOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/StatusList"
|
||||||
sha := ctx.Params("sha")
|
sha := ctx.Params("sha")
|
||||||
if len(sha) == 0 {
|
if len(sha) == 0 {
|
||||||
sha = ctx.Params("ref")
|
sha = ctx.Params("ref")
|
||||||
@ -43,10 +71,63 @@ func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) {
|
|||||||
|
|
||||||
// GetCommitStatuses returns all statuses for any given commit hash
|
// GetCommitStatuses returns all statuses for any given commit hash
|
||||||
func GetCommitStatuses(ctx *context.APIContext) {
|
func GetCommitStatuses(ctx *context.APIContext) {
|
||||||
sha := ctx.Params("sha")
|
// swagger:operation GET /repos/{owner}/{repo}/statuses/{sha} repository repoListStatuses
|
||||||
if len(sha) == 0 {
|
// ---
|
||||||
sha = ctx.Params("ref")
|
// summary: Get a commit's statuses
|
||||||
}
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: sha
|
||||||
|
// in: path
|
||||||
|
// description: sha of the commit
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/StatusList"
|
||||||
|
getCommitStatuses(ctx, ctx.Params("sha"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCommitStatusesByRef returns all statuses for any given commit ref
|
||||||
|
func GetCommitStatusesByRef(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoListStatusesByRef
|
||||||
|
// ---
|
||||||
|
// summary: Get a commit's statuses, by branch/tag/commit reference
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: ref
|
||||||
|
// in: path
|
||||||
|
// description: name of branch/tag/commit
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/StatusList"
|
||||||
|
getCommitStatuses(ctx, ctx.Params("ref"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCommitStatuses(ctx *context.APIContext, sha string) {
|
||||||
if len(sha) == 0 {
|
if len(sha) == 0 {
|
||||||
ctx.Error(400, "ref/sha not given", nil)
|
ctx.Error(400, "ref/sha not given", nil)
|
||||||
return
|
return
|
||||||
@ -78,12 +159,33 @@ type combinedCommitStatus struct {
|
|||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCombinedCommitStatus returns the combined status for any given commit hash
|
// GetCombinedCommitStatusByRef returns the combined status for any given commit hash
|
||||||
func GetCombinedCommitStatus(ctx *context.APIContext) {
|
func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
|
||||||
sha := ctx.Params("sha")
|
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoGetCombinedStatusByRef
|
||||||
if len(sha) == 0 {
|
// ---
|
||||||
sha = ctx.Params("ref")
|
// summary: Get a commit's combined status, by branch/tag/commit reference
|
||||||
}
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: ref
|
||||||
|
// in: path
|
||||||
|
// description: name of branch/tag/commit
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Status"
|
||||||
|
sha := ctx.Params("ref")
|
||||||
if len(sha) == 0 {
|
if len(sha) == 0 {
|
||||||
ctx.Error(400, "ref/sha not given", nil)
|
ctx.Error(400, "ref/sha not given", nil)
|
||||||
return
|
return
|
||||||
|
@ -12,6 +12,25 @@ import (
|
|||||||
|
|
||||||
// ListSubscribers list a repo's subscribers (i.e. watchers)
|
// ListSubscribers list a repo's subscribers (i.e. watchers)
|
||||||
func ListSubscribers(ctx *context.APIContext) {
|
func ListSubscribers(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/subscribers repository repoListSubscribers
|
||||||
|
// ---
|
||||||
|
// summary: List a repo's watchers
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
subscribers, err := ctx.Repo.Repository.GetWatchers(0)
|
subscribers, err := ctx.Repo.Repository.GetWatchers(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetWatchers", err)
|
ctx.Error(500, "GetWatchers", err)
|
||||||
|
69
routers/api/v1/swagger/issue.go
Normal file
69
routers/api/v1/swagger/issue.go
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response Issue
|
||||||
|
type swaggerResponseIssue struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Issue `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response IssueList
|
||||||
|
type swaggerResponseIssueList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Issue `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Comment
|
||||||
|
type swaggerResponseComment struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Comment `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response CommentList
|
||||||
|
type swaggerResponseCommentList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Comment `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Label
|
||||||
|
type swaggerResponseLabel struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Label `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response LabelList
|
||||||
|
type swaggerResponseLabelList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Label `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Milestone
|
||||||
|
type swaggerResponseMilestone struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Milestone `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response MilestoneList
|
||||||
|
type swaggerResponseMilestoneList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Milestone `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response TrackedTime
|
||||||
|
type swaggerResponseTrackedTime struct {
|
||||||
|
// in:body
|
||||||
|
Body api.TrackedTime `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response TrackedTimeList
|
||||||
|
type swaggerResponseTrackedTimeList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.TrackedTime `json:"body"`
|
||||||
|
}
|
45
routers/api/v1/swagger/key.go
Normal file
45
routers/api/v1/swagger/key.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response PublicKey
|
||||||
|
type swaggerResponsePublicKey struct {
|
||||||
|
// in:body
|
||||||
|
Body api.PublicKey `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response PublicKeyList
|
||||||
|
type swaggerResponsePublicKeyList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.PublicKey `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response GPGKey
|
||||||
|
type swaggerResponseGPGKey struct {
|
||||||
|
// in:body
|
||||||
|
Body api.GPGKey `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response GPGKeyList
|
||||||
|
type swaggerResponseGPGKeyList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.GPGKey `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response DeployKey
|
||||||
|
type swaggerResponseDeployKey struct {
|
||||||
|
// in:body
|
||||||
|
Body api.DeployKey `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response DeployKeyList
|
||||||
|
type swaggerResponseDeployKeyList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.DeployKey `json:"body"`
|
||||||
|
}
|
15
routers/api/v1/swagger/misc.go
Normal file
15
routers/api/v1/swagger/misc.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response ServerVersion
|
||||||
|
type swaggerResponseServerVersion struct {
|
||||||
|
// in:body
|
||||||
|
Body api.ServerVersion `json:"body"`
|
||||||
|
}
|
66
routers/api/v1/swagger/options.go
Normal file
66
routers/api/v1/swagger/options.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/modules/auth"
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// not actually a response, just a hack to get go-swagger to include definitions
|
||||||
|
// of the various XYZOption structs
|
||||||
|
|
||||||
|
// swagger:response parameterBodies
|
||||||
|
type swaggerParameterBodies struct {
|
||||||
|
AddCollaboratorOption api.AddCollaboratorOption
|
||||||
|
|
||||||
|
CreateEmailOption api.CreateEmailOption
|
||||||
|
DeleteEmailOption api.DeleteEmailOption
|
||||||
|
|
||||||
|
CreateHookOption api.CreateHookOption
|
||||||
|
EditHookOption api.EditHookOption
|
||||||
|
|
||||||
|
CreateIssueOption api.CreateIssueOption
|
||||||
|
EditIssueOption api.EditIssueOption
|
||||||
|
|
||||||
|
CreateIssueCommentOption api.CreateIssueCommentOption
|
||||||
|
EditIssueCommentOption api.EditIssueCommentOption
|
||||||
|
|
||||||
|
IssueLabelsOption api.IssueLabelsOption
|
||||||
|
|
||||||
|
CreateKeyOption api.CreateKeyOption
|
||||||
|
|
||||||
|
CreateLabelOption api.CreateLabelOption
|
||||||
|
EditLabelOption api.EditLabelOption
|
||||||
|
|
||||||
|
MarkdownOption api.MarkdownOption
|
||||||
|
|
||||||
|
CreateMilestoneOption api.CreateMilestoneOption
|
||||||
|
EditMilestoneOption api.EditMilestoneOption
|
||||||
|
|
||||||
|
CreateOrgOption api.CreateOrgOption
|
||||||
|
EditOrgOption api.EditOrgOption
|
||||||
|
|
||||||
|
CreatePullRequestOption api.CreatePullRequestOption
|
||||||
|
EditPullRequestOption api.EditPullRequestOption
|
||||||
|
|
||||||
|
CreateReleaseOption api.CreateReleaseOption
|
||||||
|
EditReleaseOption api.EditReleaseOption
|
||||||
|
|
||||||
|
CreateRepoOption api.CreateRepoOption
|
||||||
|
CreateForkOption api.CreateForkOption
|
||||||
|
|
||||||
|
CreateStatusOption api.CreateStatusOption
|
||||||
|
|
||||||
|
CreateTeamOption api.CreateTeamOption
|
||||||
|
EditTeamOption api.EditTeamOption
|
||||||
|
|
||||||
|
AddTimeOption api.AddTimeOption
|
||||||
|
|
||||||
|
CreateUserOption api.CreateUserOption
|
||||||
|
EditUserOption api.EditUserOption
|
||||||
|
|
||||||
|
MigrateRepoForm auth.MigrateRepoForm
|
||||||
|
}
|
33
routers/api/v1/swagger/org.go
Normal file
33
routers/api/v1/swagger/org.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response Organization
|
||||||
|
type swaggerResponseOrganization struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Organization `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response OrganizationList
|
||||||
|
type swaggerResponseOrganizationList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Organization `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Team
|
||||||
|
type swaggerResponseTeam struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Team `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response TeamList
|
||||||
|
type swaggerResponseTeamList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Team `json:"body"`
|
||||||
|
}
|
92
routers/api/v1/swagger/repo.go
Normal file
92
routers/api/v1/swagger/repo.go
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response Repository
|
||||||
|
type swaggerResponseRepository struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Repository `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response RepositoryList
|
||||||
|
type swaggerResponseRepositoryList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Repository `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Branch
|
||||||
|
type swaggerResponseBranch struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Branch `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response BranchList
|
||||||
|
type swaggerResponseBranchList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Branch `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Hook
|
||||||
|
type swaggerResponseHook struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Branch `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response HookList
|
||||||
|
type swaggerResponseHookList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Branch `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Release
|
||||||
|
type swaggerResponseRelease struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Release `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response ReleaseList
|
||||||
|
type swaggerResponseReleaseList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Release `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response PullRequest
|
||||||
|
type swaggerResponsePullRequest struct {
|
||||||
|
// in:body
|
||||||
|
Body api.PullRequest `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response PullRequestList
|
||||||
|
type swaggerResponsePullRequestList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.PullRequest `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response Status
|
||||||
|
type swaggerResponseStatus struct {
|
||||||
|
// in:body
|
||||||
|
Body api.Status `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response StatusList
|
||||||
|
type swaggerResponseStatusList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Status `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response WatchInfo
|
||||||
|
type swaggerResponseWatchInfo struct {
|
||||||
|
// in:body
|
||||||
|
Body api.WatchInfo `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response SearchResults
|
||||||
|
type swaggerResponseSearchResults struct {
|
||||||
|
Body api.SearchResults `json:"body"`
|
||||||
|
}
|
33
routers/api/v1/swagger/user.go
Normal file
33
routers/api/v1/swagger/user.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
// swagger:response User
|
||||||
|
type swaggerResponseUser struct {
|
||||||
|
// in:body
|
||||||
|
Body api.User `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response UserList
|
||||||
|
type swaggerResponseUserList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.User `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:response EmailList
|
||||||
|
type swaggerResponseEmailList struct {
|
||||||
|
// in:body
|
||||||
|
Body []api.Email `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// swagger:model EditUserOption
|
||||||
|
type swaggerModelEditUserOption struct {
|
||||||
|
// in:body
|
||||||
|
Options api.EditUserOption
|
||||||
|
}
|
@ -13,15 +13,14 @@ import (
|
|||||||
|
|
||||||
// ListAccessTokens list all the access tokens
|
// ListAccessTokens list all the access tokens
|
||||||
func ListAccessTokens(ctx *context.APIContext) {
|
func ListAccessTokens(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/tokens user userGetTokens
|
// swagger:operation GET /users/{username}/tokens user userGetTokens
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the authenticated user's access tokens
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: AccessTokenList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/AccessTokenList"
|
||||||
|
|
||||||
tokens, err := models.ListAccessTokens(ctx.User.ID)
|
tokens, err := models.ListAccessTokens(ctx.User.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "ListAccessTokens", err)
|
ctx.Error(500, "ListAccessTokens", err)
|
||||||
@ -40,18 +39,16 @@ func ListAccessTokens(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// CreateAccessToken create access tokens
|
// CreateAccessToken create access tokens
|
||||||
func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) {
|
func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) {
|
||||||
// swagger:route POST /users/{username} /tokens user userCreateToken
|
// swagger:operation POST /users/{username}/tokens user userCreateToken
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create an access token
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// responses:
|
||||||
// Responses:
|
// "200":
|
||||||
// 200: AccessToken
|
// "$ref": "#/responses/AccessToken"
|
||||||
// 500: error
|
|
||||||
|
|
||||||
t := &models.AccessToken{
|
t := &models.AccessToken{
|
||||||
UID: ctx.User.ID,
|
UID: ctx.User.ID,
|
||||||
Name: form.Name,
|
Name: form.Name,
|
||||||
|
@ -13,9 +13,17 @@ import (
|
|||||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListEmails list all the emails of mine
|
// ListEmails list all of the authenticated user's email addresses
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
|
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
|
||||||
func ListEmails(ctx *context.APIContext) {
|
func ListEmails(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /user/emails user userListEmails
|
||||||
|
// ---
|
||||||
|
// summary: List the authenticated user's email addresses
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/EmailList"
|
||||||
emails, err := models.GetEmailAddresses(ctx.User.ID)
|
emails, err := models.GetEmailAddresses(ctx.User.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetEmailAddresses", err)
|
ctx.Error(500, "GetEmailAddresses", err)
|
||||||
@ -28,9 +36,26 @@ func ListEmails(ctx *context.APIContext) {
|
|||||||
ctx.JSON(200, &apiEmails)
|
ctx.JSON(200, &apiEmails)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddEmail add email for me
|
// AddEmail add an email address
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
|
|
||||||
func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
||||||
|
// swagger:operation POST /user/emails user userAddEmail
|
||||||
|
// ---
|
||||||
|
// summary: Add email addresses
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: options
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateEmailOption"
|
||||||
|
// parameters:
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateEmailOption"
|
||||||
|
// responses:
|
||||||
|
// '201':
|
||||||
|
// "$ref": "#/responses/EmailList"
|
||||||
if len(form.Emails) == 0 {
|
if len(form.Emails) == 0 {
|
||||||
ctx.Status(422)
|
ctx.Status(422)
|
||||||
return
|
return
|
||||||
@ -62,8 +87,20 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteEmail delete email
|
// DeleteEmail delete email
|
||||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
|
func DeleteEmail(ctx *context.APIContext, form api.DeleteEmailOption) {
|
||||||
func DeleteEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
// swagger:operation DELETE /user/emails user userDeleteEmail
|
||||||
|
// ---
|
||||||
|
// summary: Delete email addresses
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/DeleteEmailOption"
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
if len(form.Emails) == 0 {
|
if len(form.Emails) == 0 {
|
||||||
ctx.Status(204)
|
ctx.Status(204)
|
||||||
return
|
return
|
||||||
|
@ -28,31 +28,35 @@ func listUserFollowers(ctx *context.APIContext, u *models.User) {
|
|||||||
responseAPIUsers(ctx, users)
|
responseAPIUsers(ctx, users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyFollowers list all my followers
|
// ListMyFollowers list the authenticated user's followers
|
||||||
func ListMyFollowers(ctx *context.APIContext) {
|
func ListMyFollowers(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/followers user userCurrentListFollowers
|
// swagger:operation GET /user/followers user userCurrentListFollowers
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the authenticated user's followers
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: UserList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/UserList"
|
||||||
|
|
||||||
listUserFollowers(ctx, ctx.User)
|
listUserFollowers(ctx, ctx.User)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListFollowers list user's followers
|
// ListFollowers list the given user's followers
|
||||||
func ListFollowers(ctx *context.APIContext) {
|
func ListFollowers(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/:username/followers user userListFollowers
|
// swagger:operation GET /users/{username}/followers user userListFollowers
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the given user's followers
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: UserList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
u := GetUserByParams(ctx)
|
u := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -69,31 +73,35 @@ func listUserFollowing(ctx *context.APIContext, u *models.User) {
|
|||||||
responseAPIUsers(ctx, users)
|
responseAPIUsers(ctx, users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyFollowing list all my followings
|
// ListMyFollowing list the users that the authenticated user is following
|
||||||
func ListMyFollowing(ctx *context.APIContext) {
|
func ListMyFollowing(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/following user userCurrentListFollowing
|
// swagger:operation GET /user/following user userCurrentListFollowing
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the users that the authenticated user is following
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: UserList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/UserList"
|
||||||
|
|
||||||
listUserFollowing(ctx, ctx.User)
|
listUserFollowing(ctx, ctx.User)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListFollowing list user's followings
|
// ListFollowing list the users that the given user is following
|
||||||
func ListFollowing(ctx *context.APIContext) {
|
func ListFollowing(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/following user userListFollowing
|
// swagger:operation GET /users/{username}/following user userListFollowing
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the users that the given user is following
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: UserList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
u := GetUserByParams(ctx)
|
u := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -109,14 +117,22 @@ func checkUserFollowing(ctx *context.APIContext, u *models.User, followID int64)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckMyFollowing check if the repo is followed by me
|
// CheckMyFollowing whether the given user is followed by the authenticated user
|
||||||
func CheckMyFollowing(ctx *context.APIContext) {
|
func CheckMyFollowing(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/following/{username} user userCurrentCheckFollowing
|
// swagger:operation GET /user/following/{followee} user userCurrentCheckFollowing
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Check whether a user is followed by the authenticated user
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 404: notFound
|
// - name: followee
|
||||||
|
// in: path
|
||||||
|
// description: username of followed user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
target := GetUserByParams(ctx)
|
target := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -124,14 +140,27 @@ func CheckMyFollowing(ctx *context.APIContext) {
|
|||||||
checkUserFollowing(ctx, ctx.User, target.ID)
|
checkUserFollowing(ctx, ctx.User, target.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckFollowing check if the repo is followed by user
|
// CheckFollowing check if one user is following another user
|
||||||
func CheckFollowing(ctx *context.APIContext) {
|
func CheckFollowing(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/following/:target user userCheckFollowing
|
// swagger:operation GET /users/{follower}/following/{followee} user userCheckFollowing
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Check if one user is following another user
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 404: notFound
|
// - name: follower
|
||||||
|
// in: path
|
||||||
|
// description: username of following user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: followee
|
||||||
|
// in: path
|
||||||
|
// description: username of followed user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
u := GetUserByParams(ctx)
|
u := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -143,14 +172,20 @@ func CheckFollowing(ctx *context.APIContext) {
|
|||||||
checkUserFollowing(ctx, u, target.ID)
|
checkUserFollowing(ctx, u, target.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Follow follow one repository
|
// Follow follow a user
|
||||||
func Follow(ctx *context.APIContext) {
|
func Follow(ctx *context.APIContext) {
|
||||||
// swagger:route PUT /user/following/{username} user userCurrentPutFollow
|
// swagger:operation PUT /user/following/{username} user userCurrentPutFollow
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Follow a user
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 500: error
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of user to follow
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
target := GetUserByParams(ctx)
|
target := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -162,14 +197,20 @@ func Follow(ctx *context.APIContext) {
|
|||||||
ctx.Status(204)
|
ctx.Status(204)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfollow unfollow one repository
|
// Unfollow unfollow a user
|
||||||
func Unfollow(ctx *context.APIContext) {
|
func Unfollow(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /user/following/{username} user userCurrentDeleteFollow
|
// swagger:operation DELETE /user/following/{username} user userCurrentDeleteFollow
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Unfollow a user
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 500: error
|
// - name: username
|
||||||
|
// in: path
|
||||||
|
// description: username of user to unfollow
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
target := GetUserByParams(ctx)
|
target := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
@ -34,15 +34,20 @@ func listGPGKeys(ctx *context.APIContext, uid int64) {
|
|||||||
|
|
||||||
//ListGPGKeys get the GPG key list of a user
|
//ListGPGKeys get the GPG key list of a user
|
||||||
func ListGPGKeys(ctx *context.APIContext) {
|
func ListGPGKeys(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/gpg_keys user userListGPGKeys
|
// swagger:operation GET /users/{username}/gpg_keys user userListGPGKeys
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the given user's GPG keys
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: GPGKeyList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/GPGKeyList"
|
||||||
user := GetUserByParams(ctx)
|
user := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -50,32 +55,37 @@ func ListGPGKeys(ctx *context.APIContext) {
|
|||||||
listGPGKeys(ctx, user.ID)
|
listGPGKeys(ctx, user.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
//ListMyGPGKeys get the GPG key list of the logged user
|
//ListMyGPGKeys get the GPG key list of the authenticated user
|
||||||
func ListMyGPGKeys(ctx *context.APIContext) {
|
func ListMyGPGKeys(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/gpg_keys user userCurrentListGPGKeys
|
// swagger:operation GET /user/gpg_keys user userCurrentListGPGKeys
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the authenticated user's GPG keys
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: GPGKeyList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/GPGKeyList"
|
||||||
|
|
||||||
listGPGKeys(ctx, ctx.User.ID)
|
listGPGKeys(ctx, ctx.User.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetGPGKey get the GPG key based on a id
|
//GetGPGKey get the GPG key based on a id
|
||||||
func GetGPGKey(ctx *context.APIContext) {
|
func GetGPGKey(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/gpg_keys/{id} user userCurrentGetGPGKey
|
// swagger:operation GET /user/gpg_keys/{id} user userCurrentGetGPGKey
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a GPG key
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: GPGKey
|
// - name: id
|
||||||
// 404: notFound
|
// in: path
|
||||||
// 500: error
|
// description: id of key to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/GPGKey"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
key, err := models.GetGPGKeyByID(ctx.ParamsInt64(":id"))
|
key, err := models.GetGPGKeyByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrGPGKeyNotExist(err) {
|
if models.IsErrGPGKeyNotExist(err) {
|
||||||
@ -98,36 +108,47 @@ func CreateUserGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption, uid
|
|||||||
ctx.JSON(201, convert.ToGPGKey(key))
|
ctx.JSON(201, convert.ToGPGKey(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
//CreateGPGKey associate a GPG key to the current user
|
// swagger:parameters userCurrentPostGPGKey
|
||||||
func CreateGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption) {
|
type swaggerUserCurrentPostGPGKey struct {
|
||||||
// swagger:route POST /user/gpg_keys user userCurrentPostGPGKey
|
// in:body
|
||||||
//
|
Form api.CreateGPGKeyOption
|
||||||
// Consumes:
|
}
|
||||||
// - application/json
|
|
||||||
//
|
|
||||||
// Produces:
|
|
||||||
// - application/json
|
|
||||||
//
|
|
||||||
// Responses:
|
|
||||||
// 201: GPGKey
|
|
||||||
// 422: validationError
|
|
||||||
// 500: error
|
|
||||||
|
|
||||||
|
//CreateGPGKey create a GPG key belonging to the authenticated user
|
||||||
|
func CreateGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption) {
|
||||||
|
// swagger:operation POST /user/gpg_keys user userCurrentPostGPGKey
|
||||||
|
// ---
|
||||||
|
// summary: Create a GPG key
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/GPGKey"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
CreateUserGPGKey(ctx, form, ctx.User.ID)
|
CreateUserGPGKey(ctx, form, ctx.User.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
//DeleteGPGKey remove a GPG key associated to the current user
|
//DeleteGPGKey remove a GPG key belonging to the authenticated user
|
||||||
func DeleteGPGKey(ctx *context.APIContext) {
|
func DeleteGPGKey(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /user/gpg_keys/{id} user userCurrentDeleteGPGKey
|
// swagger:operation DELETE /user/gpg_keys/{id} user userCurrentDeleteGPGKey
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Remove a GPG key
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: id
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 500: error
|
// description: id of key to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
if err := models.DeleteGPGKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
if err := models.DeleteGPGKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||||
if models.IsErrGPGKeyAccessDenied(err) {
|
if models.IsErrGPGKeyAccessDenied(err) {
|
||||||
ctx.Error(403, "", "You do not have access to this key")
|
ctx.Error(403, "", "You do not have access to this key")
|
||||||
@ -144,9 +165,9 @@ func DeleteGPGKey(ctx *context.APIContext) {
|
|||||||
func HandleAddGPGKeyError(ctx *context.APIContext, err error) {
|
func HandleAddGPGKeyError(ctx *context.APIContext, err error) {
|
||||||
switch {
|
switch {
|
||||||
case models.IsErrGPGKeyAccessDenied(err):
|
case models.IsErrGPGKeyAccessDenied(err):
|
||||||
ctx.Error(422, "", "You do not have access to this gpg key")
|
ctx.Error(422, "", "You do not have access to this GPG key")
|
||||||
case models.IsErrGPGKeyIDAlreadyUsed(err):
|
case models.IsErrGPGKeyIDAlreadyUsed(err):
|
||||||
ctx.Error(422, "", "A key with the same keyid is already in database")
|
ctx.Error(422, "", "A key with the same id already exists")
|
||||||
default:
|
default:
|
||||||
ctx.Error(500, "AddGPGKey", err)
|
ctx.Error(500, "AddGPGKey", err)
|
||||||
}
|
}
|
||||||
|
@ -53,31 +53,35 @@ func listPublicKeys(ctx *context.APIContext, uid int64) {
|
|||||||
ctx.JSON(200, &apiKeys)
|
ctx.JSON(200, &apiKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyPublicKeys list all my public keys
|
// ListMyPublicKeys list all of the authenticated user's public keys
|
||||||
func ListMyPublicKeys(ctx *context.APIContext) {
|
func ListMyPublicKeys(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/keys user userCurrentListKeys
|
// swagger:operation GET /user/keys user userCurrentListKeys
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the authenticated user's public keys
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: PublicKeyList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/PublicKeyList"
|
||||||
|
|
||||||
listPublicKeys(ctx, ctx.User.ID)
|
listPublicKeys(ctx, ctx.User.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPublicKeys list all user's public keys
|
// ListPublicKeys list the given user's public keys
|
||||||
func ListPublicKeys(ctx *context.APIContext) {
|
func ListPublicKeys(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/keys user userListKeys
|
// swagger:operation GET /users/{username}/keys user userListKeys
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the given user's public keys
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: PublicKeyList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/PublicKeyList"
|
||||||
user := GetUserByParams(ctx)
|
user := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -85,18 +89,24 @@ func ListPublicKeys(ctx *context.APIContext) {
|
|||||||
listPublicKeys(ctx, user.ID)
|
listPublicKeys(ctx, user.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPublicKey get one public key
|
// GetPublicKey get a public key
|
||||||
func GetPublicKey(ctx *context.APIContext) {
|
func GetPublicKey(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/keys/{id} user userCurrentGetKey
|
// swagger:operation GET /user/keys/{id} user userCurrentGetKey
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a public key
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: PublicKey
|
// - name: id
|
||||||
// 404: notFound
|
// in: path
|
||||||
// 500: error
|
// description: id of key to get
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/PublicKey"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrKeyNotExist(err) {
|
if models.IsErrKeyNotExist(err) {
|
||||||
@ -130,34 +140,44 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
|
|||||||
|
|
||||||
// CreatePublicKey create one public key for me
|
// CreatePublicKey create one public key for me
|
||||||
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||||
// swagger:route POST /user/keys user userCurrentPostKey
|
// swagger:operation POST /user/keys user userCurrentPostKey
|
||||||
//
|
// ---
|
||||||
// Consumes:
|
// summary: Create a public key
|
||||||
// - application/json
|
// consumes:
|
||||||
//
|
// - application/json
|
||||||
// Produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
//
|
// parameters:
|
||||||
// Responses:
|
// - name: body
|
||||||
// 201: PublicKey
|
// in: body
|
||||||
// 422: validationError
|
// schema:
|
||||||
// 500: error
|
// "$ref": "#/definitions/CreateKeyOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/PublicKey"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
CreateUserPublicKey(ctx, form, ctx.User.ID)
|
CreateUserPublicKey(ctx, form, ctx.User.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeletePublicKey delete one public key of mine
|
// DeletePublicKey delete one public key
|
||||||
func DeletePublicKey(ctx *context.APIContext) {
|
func DeletePublicKey(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /user/keys/{id} user userCurrentDeleteKey
|
// swagger:operation DELETE /user/keys/{id} user userCurrentDeleteKey
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Delete a public key
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 204: empty
|
// - name: id
|
||||||
// 403: forbidden
|
// in: path
|
||||||
// 500: error
|
// description: id of key to delete
|
||||||
|
// type: integer
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||||
if models.IsErrKeyAccessDenied(err) {
|
if models.IsErrKeyAccessDenied(err) {
|
||||||
ctx.Error(403, "", "You do not have access to this key")
|
ctx.Error(403, "", "You do not have access to this key")
|
||||||
|
@ -36,15 +36,20 @@ func listUserRepos(ctx *context.APIContext, u *models.User) {
|
|||||||
|
|
||||||
// ListUserRepos - list the repos owned by the given user.
|
// ListUserRepos - list the repos owned by the given user.
|
||||||
func ListUserRepos(ctx *context.APIContext) {
|
func ListUserRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/repos user userListRepos
|
// swagger:operation GET /users/{username}/repos user userListRepos
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the repos owned by the given user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: RepositoryList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
user := GetUserByParams(ctx)
|
user := GetUserByParams(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
@ -54,14 +59,14 @@ func ListUserRepos(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ListMyRepos - list the repositories you own or have access to.
|
// ListMyRepos - list the repositories you own or have access to.
|
||||||
func ListMyRepos(ctx *context.APIContext) {
|
func ListMyRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/repos user userCurrentListRepos
|
// swagger:operation GET /user/repos user userCurrentListRepos
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the repos that the authenticated user owns or has access to
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: RepositoryList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/RepositoryList"
|
||||||
ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos, "")
|
ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetUserRepositories", err)
|
ctx.Error(500, "GetUserRepositories", err)
|
||||||
@ -87,14 +92,19 @@ func ListMyRepos(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// ListOrgRepos - list the repositories of an organization.
|
// ListOrgRepos - list the repositories of an organization.
|
||||||
func ListOrgRepos(ctx *context.APIContext) {
|
func ListOrgRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /orgs/{orgname}/repos organization orgListRepos
|
// swagger:operation GET /orgs/{org}/repos organization orgListRepos
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List an organization's repos
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: RepositoryList
|
// - name: org
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
listUserRepos(ctx, ctx.Org.Organization)
|
listUserRepos(ctx, ctx.Org.Organization)
|
||||||
}
|
}
|
||||||
|
@ -30,18 +30,22 @@ func getStarredRepos(userID int64, private bool) ([]*api.Repository, error) {
|
|||||||
return repos, nil
|
return repos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStarredRepos returns the repos that the user specified by the APIContext
|
// GetStarredRepos returns the repos that the given user has starred
|
||||||
// has starred
|
|
||||||
func GetStarredRepos(ctx *context.APIContext) {
|
func GetStarredRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/starred user userListStarred
|
// swagger:operation GET /users/{username}/starred user userListStarred
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: The repos that the given user has starred
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: RepositoryList
|
// - name: username
|
||||||
// 500: error
|
// in: path
|
||||||
|
// description: username of user
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
user := GetUserByParams(ctx)
|
user := GetUserByParams(ctx)
|
||||||
private := user.ID == ctx.User.ID
|
private := user.ID == ctx.User.ID
|
||||||
repos, err := getStarredRepos(user.ID, private)
|
repos, err := getStarredRepos(user.ID, private)
|
||||||
@ -53,15 +57,14 @@ func GetStarredRepos(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetMyStarredRepos returns the repos that the authenticated user has starred
|
// GetMyStarredRepos returns the repos that the authenticated user has starred
|
||||||
func GetMyStarredRepos(ctx *context.APIContext) {
|
func GetMyStarredRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/starred user userCurrentListStarred
|
// swagger:operation GET /user/starred user userCurrentListStarred
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: The repos that the authenticated user has starred
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: RepositoryList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/RepositoryList"
|
||||||
|
|
||||||
repos, err := getStarredRepos(ctx.User.ID, true)
|
repos, err := getStarredRepos(ctx.User.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "getStarredRepos", err)
|
ctx.Error(500, "getStarredRepos", err)
|
||||||
@ -71,12 +74,25 @@ func GetMyStarredRepos(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// IsStarring returns whether the authenticated is starring the repo
|
// IsStarring returns whether the authenticated is starring the repo
|
||||||
func IsStarring(ctx *context.APIContext) {
|
func IsStarring(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/starred/{username}/{reponame} user userCurrentCheckStarring
|
// swagger:operation GET /user/starred/{owner}/{repo} user userCurrentCheckStarring
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Whether the authenticated is starring the repo
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 404: notFound
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
if models.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) {
|
if models.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) {
|
||||||
ctx.Status(204)
|
ctx.Status(204)
|
||||||
} else {
|
} else {
|
||||||
@ -86,12 +102,23 @@ func IsStarring(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Star the repo specified in the APIContext, as the authenticated user
|
// Star the repo specified in the APIContext, as the authenticated user
|
||||||
func Star(ctx *context.APIContext) {
|
func Star(ctx *context.APIContext) {
|
||||||
// swagger:route PUT /user/starred/{username}/{reponame} user userCurrentPutStar
|
// swagger:operation PUT /user/starred/{owner}/{repo} user userCurrentPutStar
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Star the given repo
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 500: error
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo to star
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to star
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
|
err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "StarRepo", err)
|
ctx.Error(500, "StarRepo", err)
|
||||||
@ -102,12 +129,23 @@ func Star(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Unstar the repo specified in the APIContext, as the authenticated user
|
// Unstar the repo specified in the APIContext, as the authenticated user
|
||||||
func Unstar(ctx *context.APIContext) {
|
func Unstar(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /user/starred/{username}/{reponame} user userCurrentDeleteStar
|
// swagger:operation DELETE /user/starred/{owner}/{repo} user userCurrentDeleteStar
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Unstar the given repo
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 500: error
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo to unstar
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo to unstar
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
|
err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "StarRepo", err)
|
ctx.Error(500, "StarRepo", err)
|
||||||
|
@ -17,15 +17,23 @@ import (
|
|||||||
|
|
||||||
// Search search users
|
// Search search users
|
||||||
func Search(ctx *context.APIContext) {
|
func Search(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/search user userSearch
|
// swagger:operation GET /users/search user userSearch
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Search for users
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: UserList
|
// - name: q
|
||||||
// 500: error
|
// in: query
|
||||||
|
// description: keyword
|
||||||
|
// type: string
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: maximum number of users to return
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/UserList"
|
||||||
opts := &models.SearchUserOptions{
|
opts := &models.SearchUserOptions{
|
||||||
Keyword: strings.Trim(ctx.Query("q"), " "),
|
Keyword: strings.Trim(ctx.Query("q"), " "),
|
||||||
Type: models.UserTypeIndividual,
|
Type: models.UserTypeIndividual,
|
||||||
@ -65,16 +73,22 @@ func Search(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetInfo get user's information
|
// GetInfo get user's information
|
||||||
func GetInfo(ctx *context.APIContext) {
|
func GetInfo(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username} user userGet
|
// swagger:operation GET /users/{username} user userGet
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get a user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: User
|
// - name: username
|
||||||
// 404: notFound
|
// in: path
|
||||||
// 500: error
|
// description: username of user to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/User"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if models.IsErrUserNotExist(err) {
|
||||||
@ -92,15 +106,15 @@ func GetInfo(ctx *context.APIContext) {
|
|||||||
ctx.JSON(200, u.APIFormat())
|
ctx.JSON(200, u.APIFormat())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAuthenticatedUser get curent user's information
|
// GetAuthenticatedUser get current user's information
|
||||||
func GetAuthenticatedUser(ctx *context.APIContext) {
|
func GetAuthenticatedUser(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user user userGetCurrent
|
// swagger:operation GET /user user userGetCurrent
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: Get the authenticated user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: User
|
// "200":
|
||||||
|
// "$ref": "#/responses/User"
|
||||||
ctx.JSON(200, ctx.User.APIFormat())
|
ctx.JSON(200, ctx.User.APIFormat())
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,19 @@ func getWatchedRepos(userID int64, private bool) ([]*api.Repository, error) {
|
|||||||
|
|
||||||
// GetWatchedRepos returns the repos that the user specified in ctx is watching
|
// GetWatchedRepos returns the repos that the user specified in ctx is watching
|
||||||
func GetWatchedRepos(ctx *context.APIContext) {
|
func GetWatchedRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /users/{username}/subscriptions user userListSubscriptions
|
// swagger:operation GET /users/{username}/subscriptions user userListSubscriptions
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List the repositories watched by a user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// parameters:
|
||||||
// 200: RepositoryList
|
// - name: username
|
||||||
// 500: error
|
// type: string
|
||||||
|
// in: path
|
||||||
|
// description: username of the user
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepositoryList"
|
||||||
user := GetUserByParams(ctx)
|
user := GetUserByParams(ctx)
|
||||||
private := user.ID == ctx.User.ID
|
private := user.ID == ctx.User.ID
|
||||||
repos, err := getWatchedRepos(user.ID, private)
|
repos, err := getWatchedRepos(user.ID, private)
|
||||||
@ -53,15 +57,14 @@ func GetWatchedRepos(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// GetMyWatchedRepos returns the repos that the authenticated user is watching
|
// GetMyWatchedRepos returns the repos that the authenticated user is watching
|
||||||
func GetMyWatchedRepos(ctx *context.APIContext) {
|
func GetMyWatchedRepos(ctx *context.APIContext) {
|
||||||
// swagger:route GET /user/subscriptions user userCurrentListSubscriptions
|
// swagger:operation GET /user/subscriptions user userCurrentListSubscriptions
|
||||||
//
|
// ---
|
||||||
// Produces:
|
// summary: List repositories watched by the authenticated user
|
||||||
// - application/json
|
// produces:
|
||||||
//
|
// - application/json
|
||||||
// Responses:
|
// responses:
|
||||||
// 200: RepositoryList
|
// "200":
|
||||||
// 500: error
|
// "$ref": "#/responses/RepositoryList"
|
||||||
|
|
||||||
repos, err := getWatchedRepos(ctx.User.ID, true)
|
repos, err := getWatchedRepos(ctx.User.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "getWatchedRepos", err)
|
ctx.Error(500, "getWatchedRepos", err)
|
||||||
@ -72,12 +75,23 @@ func GetMyWatchedRepos(ctx *context.APIContext) {
|
|||||||
// IsWatching returns whether the authenticated user is watching the repo
|
// IsWatching returns whether the authenticated user is watching the repo
|
||||||
// specified in ctx
|
// specified in ctx
|
||||||
func IsWatching(ctx *context.APIContext) {
|
func IsWatching(ctx *context.APIContext) {
|
||||||
// swagger:route GET /repos/{username}/{reponame}/subscription repository userCurrentCheckSubscription
|
// swagger:operation GET /repos/{owner}/{repo}/subscription repository userCurrentCheckSubscription
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Check if the current user is watching a repo
|
||||||
// 200: WatchInfo
|
// parameters:
|
||||||
// 404: notFound
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/WatchInfo"
|
||||||
if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
|
if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
|
||||||
ctx.JSON(200, api.WatchInfo{
|
ctx.JSON(200, api.WatchInfo{
|
||||||
Subscribed: true,
|
Subscribed: true,
|
||||||
@ -94,12 +108,23 @@ func IsWatching(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Watch the repo specified in ctx, as the authenticated user
|
// Watch the repo specified in ctx, as the authenticated user
|
||||||
func Watch(ctx *context.APIContext) {
|
func Watch(ctx *context.APIContext) {
|
||||||
// swagger:route PUT /repos/{username}/{reponame}/subscription repository userCurrentPutSubscription
|
// swagger:operation PUT /repos/{owner}/{repo}/subscription repository userCurrentPutSubscription
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Watch a repo
|
||||||
// 200: WatchInfo
|
// parameters:
|
||||||
// 500: error
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/WatchInfo"
|
||||||
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
|
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "WatchRepo", err)
|
ctx.Error(500, "WatchRepo", err)
|
||||||
@ -118,12 +143,23 @@ func Watch(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Unwatch the repo specified in ctx, as the authenticated user
|
// Unwatch the repo specified in ctx, as the authenticated user
|
||||||
func Unwatch(ctx *context.APIContext) {
|
func Unwatch(ctx *context.APIContext) {
|
||||||
// swagger:route DELETE /repos/{username}/{reponame}/subscription repository userCurrentDeleteSubscription
|
// swagger:operation DELETE /repos/{owner}/{repo}/subscription repository userCurrentDeleteSubscription
|
||||||
//
|
// ---
|
||||||
// Responses:
|
// summary: Unwatch a repo
|
||||||
// 204: empty
|
// parameters:
|
||||||
// 500: error
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
|
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "UnwatchRepo", err)
|
ctx.Error(500, "UnwatchRepo", err)
|
||||||
|
29
vendor/code.gitea.io/sdk/gitea/admin_user.go
generated
vendored
29
vendor/code.gitea.io/sdk/gitea/admin_user.go
generated
vendored
@ -11,21 +11,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateUserOption create user options
|
// CreateUserOption create user options
|
||||||
// swagger:parameters adminCreateUser
|
|
||||||
type CreateUserOption struct {
|
type CreateUserOption struct {
|
||||||
// in: body
|
|
||||||
SourceID int64 `json:"source_id"`
|
SourceID int64 `json:"source_id"`
|
||||||
// in: body
|
|
||||||
LoginName string `json:"login_name"`
|
LoginName string `json:"login_name"`
|
||||||
// in: body
|
// required: true
|
||||||
Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"`
|
Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||||||
// in: body
|
|
||||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||||
// in: body
|
// required: true
|
||||||
|
// swagger:strfmt email
|
||||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||||
// in: body
|
// required: true
|
||||||
Password string `json:"password" binding:"MaxSize(255)"`
|
Password string `json:"password" binding:"Required;MaxSize(255)"`
|
||||||
// in: body
|
|
||||||
SendNotify bool `json:"send_notify"`
|
SendNotify bool `json:"send_notify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,31 +36,20 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EditUserOption edit user options
|
// EditUserOption edit user options
|
||||||
// swagger:parameters adminEditUser
|
|
||||||
type EditUserOption struct {
|
type EditUserOption struct {
|
||||||
// in: body
|
|
||||||
SourceID int64 `json:"source_id"`
|
SourceID int64 `json:"source_id"`
|
||||||
// in: body
|
|
||||||
LoginName string `json:"login_name"`
|
LoginName string `json:"login_name"`
|
||||||
// in: body
|
|
||||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||||
// in: body
|
// required: true
|
||||||
|
// swagger:strfmt email
|
||||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||||
// in: body
|
|
||||||
Password string `json:"password" binding:"MaxSize(255)"`
|
Password string `json:"password" binding:"MaxSize(255)"`
|
||||||
// in: body
|
|
||||||
Website string `json:"website" binding:"MaxSize(50)"`
|
Website string `json:"website" binding:"MaxSize(50)"`
|
||||||
// in: body
|
|
||||||
Location string `json:"location" binding:"MaxSize(50)"`
|
Location string `json:"location" binding:"MaxSize(50)"`
|
||||||
// in: body
|
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
// in: body
|
|
||||||
Admin *bool `json:"admin"`
|
Admin *bool `json:"admin"`
|
||||||
// in: body
|
|
||||||
AllowGitHook *bool `json:"allow_git_hook"`
|
AllowGitHook *bool `json:"allow_git_hook"`
|
||||||
// in: body
|
|
||||||
AllowImportLocal *bool `json:"allow_import_local"`
|
AllowImportLocal *bool `json:"allow_import_local"`
|
||||||
// in: body
|
|
||||||
MaxRepoCreation *int `json:"max_repo_creation"`
|
MaxRepoCreation *int `json:"max_repo_creation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
vendor/code.gitea.io/sdk/gitea/attachment.go
generated
vendored
Normal file
17
vendor/code.gitea.io/sdk/gitea/attachment.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
package gitea // import "code.gitea.io/sdk/gitea"
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Attachment a generic attachment
|
||||||
|
type Attachment struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Size int64 `json:"size"`
|
||||||
|
DownloadCount int64 `json:"download_count"`
|
||||||
|
Created time.Time `json:"created_at"`
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
DownloadURL string `json:"browser_download_url"`
|
||||||
|
}
|
3
vendor/code.gitea.io/sdk/gitea/fork.go
generated
vendored
3
vendor/code.gitea.io/sdk/gitea/fork.go
generated
vendored
@ -20,9 +20,8 @@ func (c *Client) ListForks(user, repo string) ([]*Repository, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateForkOption options for creating a fork
|
// CreateForkOption options for creating a fork
|
||||||
// swagger:parameters createFork
|
|
||||||
type CreateForkOption struct {
|
type CreateForkOption struct {
|
||||||
// in: body
|
// organization name, if forking into an organization
|
||||||
Organization *string `json:"organization"`
|
Organization *string `json:"organization"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
vendor/code.gitea.io/sdk/gitea/hook.go
generated
vendored
30
vendor/code.gitea.io/sdk/gitea/hook.go
generated
vendored
@ -20,7 +20,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Hook a hook is a web hook when one repository changed
|
// Hook a hook is a web hook when one repository changed
|
||||||
// swagger:response Hook
|
|
||||||
type Hook struct {
|
type Hook struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@ -28,12 +27,13 @@ type Hook struct {
|
|||||||
Config map[string]string `json:"config"`
|
Config map[string]string `json:"config"`
|
||||||
Events []string `json:"events"`
|
Events []string `json:"events"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HookList represents a list of API hook.
|
// HookList represents a list of API hook.
|
||||||
// swagger:response HookList
|
|
||||||
type HookList []*Hook
|
type HookList []*Hook
|
||||||
|
|
||||||
// ListOrgHooks list all the hooks of one organization
|
// ListOrgHooks list all the hooks of one organization
|
||||||
@ -61,15 +61,14 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateHookOption options when create a hook
|
// CreateHookOption options when create a hook
|
||||||
// swagger:parameters orgCreateHook repoCreateHook
|
|
||||||
type CreateHookOption struct {
|
type CreateHookOption struct {
|
||||||
// in: body
|
// required: true
|
||||||
|
// enum: gitea,gogs,slack,discord
|
||||||
Type string `json:"type" binding:"Required"`
|
Type string `json:"type" binding:"Required"`
|
||||||
// in: body
|
// required: true
|
||||||
Config map[string]string `json:"config" binding:"Required"`
|
Config map[string]string `json:"config" binding:"Required"`
|
||||||
// in: body
|
|
||||||
Events []string `json:"events"`
|
Events []string `json:"events"`
|
||||||
// in: body
|
// default: false
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +93,9 @@ func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EditHookOption options when modify one hook
|
// EditHookOption options when modify one hook
|
||||||
// swagger:parameters orgEditHook repoEditHook
|
|
||||||
type EditHookOption struct {
|
type EditHookOption struct {
|
||||||
// in: body
|
|
||||||
Config map[string]string `json:"config"`
|
Config map[string]string `json:"config"`
|
||||||
// in: body
|
|
||||||
Events []string `json:"events"`
|
Events []string `json:"events"`
|
||||||
// in: body
|
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,25 +137,32 @@ type Payloader interface {
|
|||||||
JSONPayload() ([]byte, error)
|
JSONPayload() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayloadUser FIXME
|
// PayloadUser represents the author or committer of a commit
|
||||||
type PayloadUser struct {
|
type PayloadUser struct {
|
||||||
|
// Full name of the commit author
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
// swagger:strfmt email
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
UserName string `json:"username"`
|
UserName string `json:"username"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayloadCommit FIXME: consider use same format as API when commits API are added.
|
// FIXME: consider using same format as API when commits API are added.
|
||||||
|
// applies to PayloadCommit and PayloadCommitVerification
|
||||||
|
|
||||||
|
// PayloadCommit represents a commit
|
||||||
type PayloadCommit struct {
|
type PayloadCommit struct {
|
||||||
|
// sha1 hash of the commit
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Author *PayloadUser `json:"author"`
|
Author *PayloadUser `json:"author"`
|
||||||
Committer *PayloadUser `json:"committer"`
|
Committer *PayloadUser `json:"committer"`
|
||||||
Verification *PayloadCommitVerification `json:"verification"`
|
Verification *PayloadCommitVerification `json:"verification"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayloadCommitVerification represent the GPG verification part of a commit. FIXME: like PayloadCommit consider use same format as API when commits API are added.
|
// PayloadCommitVerification represents the GPG verification of a commit
|
||||||
type PayloadCommitVerification struct {
|
type PayloadCommitVerification struct {
|
||||||
Verified bool `json:"verified"`
|
Verified bool `json:"verified"`
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
|
15
vendor/code.gitea.io/sdk/gitea/issue.go
generated
vendored
15
vendor/code.gitea.io/sdk/gitea/issue.go
generated
vendored
@ -27,7 +27,8 @@ type PullRequestMeta struct {
|
|||||||
Merged *time.Time `json:"merged_at"`
|
Merged *time.Time `json:"merged_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue an issue to a repository
|
// Issue represents an issue in a repository
|
||||||
|
// swagger:model
|
||||||
type Issue struct {
|
type Issue struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
@ -38,9 +39,15 @@ type Issue struct {
|
|||||||
Labels []*Label `json:"labels"`
|
Labels []*Label `json:"labels"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
Assignee *User `json:"assignee"`
|
Assignee *User `json:"assignee"`
|
||||||
|
// Whether the issue is open or closed
|
||||||
|
//
|
||||||
|
// type: string
|
||||||
|
// enum: open,closed
|
||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
Comments int `json:"comments"`
|
Comments int `json:"comments"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
|
|
||||||
PullRequest *PullRequestMeta `json:"pull_request"`
|
PullRequest *PullRequestMeta `json:"pull_request"`
|
||||||
@ -78,10 +85,14 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) {
|
|||||||
|
|
||||||
// CreateIssueOption options to create one issue
|
// CreateIssueOption options to create one issue
|
||||||
type CreateIssueOption struct {
|
type CreateIssueOption struct {
|
||||||
|
// required:true
|
||||||
Title string `json:"title" binding:"Required"`
|
Title string `json:"title" binding:"Required"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
|
// username of assignee
|
||||||
Assignee string `json:"assignee"`
|
Assignee string `json:"assignee"`
|
||||||
|
// milestone id
|
||||||
Milestone int64 `json:"milestone"`
|
Milestone int64 `json:"milestone"`
|
||||||
|
// list of label ids
|
||||||
Labels []int64 `json:"labels"`
|
Labels []int64 `json:"labels"`
|
||||||
Closed bool `json:"closed"`
|
Closed bool `json:"closed"`
|
||||||
}
|
}
|
||||||
@ -97,7 +108,7 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue,
|
|||||||
jsonHeader, bytes.NewReader(body), issue)
|
jsonHeader, bytes.NewReader(body), issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditIssueOption edit issue options
|
// EditIssueOption options for editing an issue
|
||||||
type EditIssueOption struct {
|
type EditIssueOption struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Body *string `json:"body"`
|
Body *string `json:"body"`
|
||||||
|
10
vendor/code.gitea.io/sdk/gitea/issue_comment.go
generated
vendored
10
vendor/code.gitea.io/sdk/gitea/issue_comment.go
generated
vendored
@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Comment represents a comment in commit and issue page.
|
// Comment represents a comment on a commit or issue
|
||||||
type Comment struct {
|
type Comment struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
HTMLURL string `json:"html_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
@ -19,7 +19,9 @@ type Comment struct {
|
|||||||
IssueURL string `json:"issue_url"`
|
IssueURL string `json:"issue_url"`
|
||||||
Poster *User `json:"user"`
|
Poster *User `json:"user"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,8 +37,9 @@ func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
|
|||||||
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
|
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssueCommentOption is option when creating an issue comment.
|
// CreateIssueCommentOption options for creating a comment on an issue
|
||||||
type CreateIssueCommentOption struct {
|
type CreateIssueCommentOption struct {
|
||||||
|
// required:true
|
||||||
Body string `json:"body" binding:"Required"`
|
Body string `json:"body" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,8 +53,9 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI
|
|||||||
return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment)
|
return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditIssueCommentOption is option when editing an issue comment.
|
// EditIssueCommentOption options for editing a comment
|
||||||
type EditIssueCommentOption struct {
|
type EditIssueCommentOption struct {
|
||||||
|
// required: true
|
||||||
Body string `json:"body" binding:"Required"`
|
Body string `json:"body" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
vendor/code.gitea.io/sdk/gitea/issue_label.go
generated
vendored
14
vendor/code.gitea.io/sdk/gitea/issue_label.go
generated
vendored
@ -11,14 +11,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Label a label to an issue or a pr
|
// Label a label to an issue or a pr
|
||||||
|
// swagger:model
|
||||||
type Label struct {
|
type Label struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
// example: 00aabb
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoLabels list lables of one reppsitory
|
// ListRepoLabels list labels of one repository
|
||||||
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
||||||
labels := make([]*Label, 0, 10)
|
labels := make([]*Label, 0, 10)
|
||||||
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
|
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
|
||||||
@ -31,9 +33,12 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
|
|||||||
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
|
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateLabelOption create options when one label of repository
|
// CreateLabelOption options for creating a label
|
||||||
type CreateLabelOption struct {
|
type CreateLabelOption struct {
|
||||||
|
// required:true
|
||||||
Name string `json:"name" binding:"Required"`
|
Name string `json:"name" binding:"Required"`
|
||||||
|
// required:true
|
||||||
|
// example: #00aabb
|
||||||
Color string `json:"color" binding:"Required;Size(7)"`
|
Color string `json:"color" binding:"Required;Size(7)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +53,7 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label,
|
|||||||
jsonHeader, bytes.NewReader(body), label)
|
jsonHeader, bytes.NewReader(body), label)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditLabelOption edit label options
|
// EditLabelOption options for editing a label
|
||||||
type EditLabelOption struct {
|
type EditLabelOption struct {
|
||||||
Name *string `json:"name"`
|
Name *string `json:"name"`
|
||||||
Color *string `json:"color"`
|
Color *string `json:"color"`
|
||||||
@ -71,8 +76,9 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// IssueLabelsOption list one issue's labels options
|
// IssueLabelsOption a collection of labels
|
||||||
type IssueLabelsOption struct {
|
type IssueLabelsOption struct {
|
||||||
|
// list of label IDs
|
||||||
Labels []int64 `json:"labels"`
|
Labels []int64 `json:"labels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
vendor/code.gitea.io/sdk/gitea/issue_milestone.go
generated
vendored
7
vendor/code.gitea.io/sdk/gitea/issue_milestone.go
generated
vendored
@ -19,7 +19,9 @@ type Milestone struct {
|
|||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
OpenIssues int `json:"open_issues"`
|
OpenIssues int `json:"open_issues"`
|
||||||
ClosedIssues int `json:"closed_issues"`
|
ClosedIssues int `json:"closed_issues"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Closed *time.Time `json:"closed_at"`
|
Closed *time.Time `json:"closed_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Deadline *time.Time `json:"due_on"`
|
Deadline *time.Time `json:"due_on"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +37,11 @@ func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error)
|
|||||||
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
|
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMilestoneOption options when creating milestone
|
// CreateMilestoneOption options for creating a milestone
|
||||||
type CreateMilestoneOption struct {
|
type CreateMilestoneOption struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Deadline *time.Time `json:"due_on"`
|
Deadline *time.Time `json:"due_on"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption)
|
|||||||
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
|
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditMilestoneOption options when modify milestone
|
// EditMilestoneOption options for editing a milestone
|
||||||
type EditMilestoneOption struct {
|
type EditMilestoneOption struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
|
9
vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go
generated
vendored
9
vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go
generated
vendored
@ -12,9 +12,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TrackedTime worked time for an issue / pr
|
// TrackedTime worked time for an issue / pr
|
||||||
// swagger:response TrackedTime
|
|
||||||
type TrackedTime struct {
|
type TrackedTime struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
// Time in seconds
|
// Time in seconds
|
||||||
Time int64 `json:"time"`
|
Time int64 `json:"time"`
|
||||||
@ -23,7 +23,6 @@ type TrackedTime struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TrackedTimes represent a list of tracked times
|
// TrackedTimes represent a list of tracked times
|
||||||
// swagger:response TrackedTimes
|
|
||||||
type TrackedTimes []*TrackedTime
|
type TrackedTimes []*TrackedTime
|
||||||
|
|
||||||
// GetUserTrackedTimes list tracked times of a user
|
// GetUserTrackedTimes list tracked times of a user
|
||||||
@ -44,10 +43,10 @@ func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) {
|
|||||||
return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×)
|
return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddTimeOption adds time manually to an issue
|
// AddTimeOption options for adding time to an issue
|
||||||
// swagger:parameters addTime
|
|
||||||
type AddTimeOption struct {
|
type AddTimeOption struct {
|
||||||
// in: body
|
// time in seconds
|
||||||
|
// required: true
|
||||||
Time int64 `json:"time" binding:"Required"`
|
Time int64 `json:"time" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
vendor/code.gitea.io/sdk/gitea/miscellaneous.go
generated
vendored
10
vendor/code.gitea.io/sdk/gitea/miscellaneous.go
generated
vendored
@ -4,22 +4,19 @@
|
|||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
// SearchResults results of search
|
// SearchResults results of a successful search
|
||||||
// swagger:response SearchResults
|
|
||||||
type SearchResults struct {
|
type SearchResults struct {
|
||||||
OK bool `json:"ok"`
|
OK bool `json:"ok"`
|
||||||
Data []*Repository `json:"data"`
|
Data []*Repository `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchError error of failing search
|
// SearchError error of a failed search
|
||||||
// swagger:response SearchError
|
|
||||||
type SearchError struct {
|
type SearchError struct {
|
||||||
OK bool `json:"ok"`
|
OK bool `json:"ok"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkdownOption markdown options
|
// MarkdownOption markdown options
|
||||||
// swagger:parameters renderMarkdown
|
|
||||||
type MarkdownOption struct {
|
type MarkdownOption struct {
|
||||||
// Text markdown to render
|
// Text markdown to render
|
||||||
//
|
//
|
||||||
@ -44,9 +41,8 @@ type MarkdownOption struct {
|
|||||||
type MarkdownRender string
|
type MarkdownRender string
|
||||||
|
|
||||||
// ServerVersion wraps the version of the server
|
// ServerVersion wraps the version of the server
|
||||||
// swagger:response ServerVersion
|
|
||||||
type ServerVersion struct {
|
type ServerVersion struct {
|
||||||
Version string
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerVersion returns the version of the server
|
// ServerVersion returns the version of the server
|
||||||
|
14
vendor/code.gitea.io/sdk/gitea/org.go
generated
vendored
14
vendor/code.gitea.io/sdk/gitea/org.go
generated
vendored
@ -10,8 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Organization a group of some repositories, users and teams
|
// Organization represents an organization
|
||||||
// swagger:response Organization
|
|
||||||
type Organization struct {
|
type Organization struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
UserName string `json:"username"`
|
UserName string `json:"username"`
|
||||||
@ -40,22 +39,17 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) {
|
|||||||
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
|
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrgOption create one organization options
|
// CreateOrgOption options for creating an organization
|
||||||
// swagger:parameters adminCreateOrg
|
|
||||||
type CreateOrgOption struct {
|
type CreateOrgOption struct {
|
||||||
// in: body
|
// required: true
|
||||||
UserName string `json:"username" binding:"Required"`
|
UserName string `json:"username" binding:"Required"`
|
||||||
// in: body
|
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
// in: body
|
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
// in: body
|
|
||||||
Website string `json:"website"`
|
Website string `json:"website"`
|
||||||
// in: body
|
|
||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditOrgOption edit one organization options
|
// EditOrgOption options for editing an organization
|
||||||
type EditOrgOption struct {
|
type EditOrgOption struct {
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
11
vendor/code.gitea.io/sdk/gitea/org_team.go
generated
vendored
11
vendor/code.gitea.io/sdk/gitea/org_team.go
generated
vendored
@ -4,24 +4,29 @@
|
|||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
// Team is a sub virtual organization of one Organization
|
// Team represents a team in an organization
|
||||||
type Team struct {
|
type Team struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
// enum: none,read,write,admin,owner
|
||||||
Permission string `json:"permission"`
|
Permission string `json:"permission"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTeamOption options when create team
|
// CreateTeamOption options for creating a team
|
||||||
type CreateTeamOption struct {
|
type CreateTeamOption struct {
|
||||||
|
// required: true
|
||||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
||||||
Description string `json:"description" binding:"MaxSize(255)"`
|
Description string `json:"description" binding:"MaxSize(255)"`
|
||||||
|
// enum: read,write,admin
|
||||||
Permission string `json:"permission"`
|
Permission string `json:"permission"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditTeamOption options when edit team
|
// EditTeamOption options for editing a team
|
||||||
type EditTeamOption struct {
|
type EditTeamOption struct {
|
||||||
|
// required: true
|
||||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
||||||
Description string `json:"description" binding:"MaxSize(255)"`
|
Description string `json:"description" binding:"MaxSize(255)"`
|
||||||
|
// enum: read,write,admin
|
||||||
Permission string `json:"permission"`
|
Permission string `json:"permission"`
|
||||||
}
|
}
|
||||||
|
9
vendor/code.gitea.io/sdk/gitea/pull.go
generated
vendored
9
vendor/code.gitea.io/sdk/gitea/pull.go
generated
vendored
@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PullRequest represents a pull request API object.
|
// PullRequest represents a pull request
|
||||||
type PullRequest struct {
|
type PullRequest struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
@ -31,6 +31,7 @@ type PullRequest struct {
|
|||||||
|
|
||||||
Mergeable bool `json:"mergeable"`
|
Mergeable bool `json:"mergeable"`
|
||||||
HasMerged bool `json:"merged"`
|
HasMerged bool `json:"merged"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Merged *time.Time `json:"merged_at"`
|
Merged *time.Time `json:"merged_at"`
|
||||||
MergedCommitID *string `json:"merge_commit_sha"`
|
MergedCommitID *string `json:"merge_commit_sha"`
|
||||||
MergedBy *User `json:"merged_by"`
|
MergedBy *User `json:"merged_by"`
|
||||||
@ -39,11 +40,13 @@ type PullRequest struct {
|
|||||||
Head *PRBranchInfo `json:"head"`
|
Head *PRBranchInfo `json:"head"`
|
||||||
MergeBase string `json:"merge_base"`
|
MergeBase string `json:"merge_base"`
|
||||||
|
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created *time.Time `json:"created_at"`
|
Created *time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated *time.Time `json:"updated_at"`
|
Updated *time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRBranchInfo base branch info when send a PR
|
// PRBranchInfo information about a branch
|
||||||
type PRBranchInfo struct {
|
type PRBranchInfo struct {
|
||||||
Name string `json:"label"`
|
Name string `json:"label"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
@ -52,7 +55,7 @@ type PRBranchInfo struct {
|
|||||||
Repository *Repository `json:"repo"`
|
Repository *Repository `json:"repo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPullRequestsOptions options when list PRs
|
// ListPullRequestsOptions options for listing pull requests
|
||||||
type ListPullRequestsOptions struct {
|
type ListPullRequestsOptions struct {
|
||||||
Page int `json:"page"`
|
Page int `json:"page"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
|
3
vendor/code.gitea.io/sdk/gitea/release.go
generated
vendored
3
vendor/code.gitea.io/sdk/gitea/release.go
generated
vendored
@ -23,7 +23,9 @@ type Release struct {
|
|||||||
ZipURL string `json:"zipball_url"`
|
ZipURL string `json:"zipball_url"`
|
||||||
IsDraft bool `json:"draft"`
|
IsDraft bool `json:"draft"`
|
||||||
IsPrerelease bool `json:"prerelease"`
|
IsPrerelease bool `json:"prerelease"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
PublishedAt time.Time `json:"published_at"`
|
PublishedAt time.Time `json:"published_at"`
|
||||||
Publisher *User `json:"author"`
|
Publisher *User `json:"author"`
|
||||||
}
|
}
|
||||||
@ -48,6 +50,7 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) {
|
|||||||
|
|
||||||
// CreateReleaseOption options when creating a release
|
// CreateReleaseOption options when creating a release
|
||||||
type CreateReleaseOption struct {
|
type CreateReleaseOption struct {
|
||||||
|
// required: true
|
||||||
TagName string `json:"tag_name" binding:"Required"`
|
TagName string `json:"tag_name" binding:"Required"`
|
||||||
Target string `json:"target_commitish"`
|
Target string `json:"target_commitish"`
|
||||||
Title string `json:"name"`
|
Title string `json:"name"`
|
||||||
|
45
vendor/code.gitea.io/sdk/gitea/repo.go
generated
vendored
45
vendor/code.gitea.io/sdk/gitea/repo.go
generated
vendored
@ -11,15 +11,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Permission represents a API permission.
|
// Permission represents a set of permissions
|
||||||
type Permission struct {
|
type Permission struct {
|
||||||
Admin bool `json:"admin"`
|
Admin bool `json:"admin"`
|
||||||
Push bool `json:"push"`
|
Push bool `json:"push"`
|
||||||
Pull bool `json:"pull"`
|
Pull bool `json:"pull"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repository represents a API repository.
|
// Repository represents a repository
|
||||||
// swagger:response Repository
|
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Owner *User `json:"owner"`
|
Owner *User `json:"owner"`
|
||||||
@ -41,15 +40,13 @@ type Repository struct {
|
|||||||
Watchers int `json:"watchers_count"`
|
Watchers int `json:"watchers_count"`
|
||||||
OpenIssues int `json:"open_issues_count"`
|
OpenIssues int `json:"open_issues_count"`
|
||||||
DefaultBranch string `json:"default_branch"`
|
DefaultBranch string `json:"default_branch"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
Permissions *Permission `json:"permissions,omitempty"`
|
Permissions *Permission `json:"permissions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepositoryList represents a list of API repository.
|
|
||||||
// swagger:response RepositoryList
|
|
||||||
type RepositoryList []*Repository
|
|
||||||
|
|
||||||
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
||||||
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
repos := make([]*Repository, 0, 10)
|
||||||
@ -69,36 +66,24 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateRepoOption options when creating repository
|
// CreateRepoOption options when creating repository
|
||||||
//swagger:parameters createOrgRepo adminCreateRepo createCurrentUserRepo
|
// swagger:model
|
||||||
type CreateRepoOption struct {
|
type CreateRepoOption struct {
|
||||||
// Name of the repository to create
|
// Name of the repository to create
|
||||||
//
|
//
|
||||||
// in: body
|
// required: true
|
||||||
// unique: true
|
// unique: true
|
||||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||||
// Description of the repository to create
|
// Description of the repository to create
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
Description string `json:"description" binding:"MaxSize(255)"`
|
Description string `json:"description" binding:"MaxSize(255)"`
|
||||||
// Is the repository to create private ?
|
// Whether the repository is private
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
Private bool `json:"private"`
|
Private bool `json:"private"`
|
||||||
// Init the repository to create ?
|
// Whether the repository should be auto-intialized?
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
AutoInit bool `json:"auto_init"`
|
AutoInit bool `json:"auto_init"`
|
||||||
// Gitignores to use
|
// Gitignores to use
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
Gitignores string `json:"gitignores"`
|
Gitignores string `json:"gitignores"`
|
||||||
// License to use
|
// License to use
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
License string `json:"license"`
|
License string `json:"license"`
|
||||||
// Readme of the repository to create
|
// Readme of the repository to create
|
||||||
//
|
|
||||||
// in: body
|
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,24 +119,18 @@ func (c *Client) DeleteRepo(owner, repo string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateRepoOption options when migrate repository from an external place
|
// MigrateRepoOption options for migrating a repository from an external service
|
||||||
// swagger:parameters repoMigrate
|
|
||||||
type MigrateRepoOption struct {
|
type MigrateRepoOption struct {
|
||||||
// in: body
|
// required: true
|
||||||
CloneAddr string `json:"clone_addr" binding:"Required"`
|
CloneAddr string `json:"clone_addr" binding:"Required"`
|
||||||
// in: body
|
|
||||||
AuthUsername string `json:"auth_username"`
|
AuthUsername string `json:"auth_username"`
|
||||||
// in: body
|
|
||||||
AuthPassword string `json:"auth_password"`
|
AuthPassword string `json:"auth_password"`
|
||||||
// in: body
|
// required: true
|
||||||
UID int `json:"uid" binding:"Required"`
|
UID int `json:"uid" binding:"Required"`
|
||||||
// in: body
|
// required: true
|
||||||
RepoName string `json:"repo_name" binding:"Required"`
|
RepoName string `json:"repo_name" binding:"Required"`
|
||||||
// in: body
|
|
||||||
Mirror bool `json:"mirror"`
|
Mirror bool `json:"mirror"`
|
||||||
// in: body
|
|
||||||
Private bool `json:"private"`
|
Private bool `json:"private"`
|
||||||
// in: body
|
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/code.gitea.io/sdk/gitea/repo_branch.go
generated
vendored
2
vendor/code.gitea.io/sdk/gitea/repo_branch.go
generated
vendored
@ -8,7 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Branch represents a repository branch.
|
// Branch represents a repository branch
|
||||||
type Branch struct {
|
type Branch struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Commit *PayloadCommit `json:"commit"`
|
Commit *PayloadCommit `json:"commit"`
|
||||||
|
2
vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
generated
vendored
2
vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
generated
vendored
@ -33,7 +33,7 @@ func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCollaboratorOption options when add some user as a collaborator of a repository
|
// AddCollaboratorOption options when adding a user as a collaborator of a repository
|
||||||
type AddCollaboratorOption struct {
|
type AddCollaboratorOption struct {
|
||||||
Permission *string `json:"permission"`
|
Permission *string `json:"permission"`
|
||||||
}
|
}
|
||||||
|
6
vendor/code.gitea.io/sdk/gitea/repo_key.go
generated
vendored
6
vendor/code.gitea.io/sdk/gitea/repo_key.go
generated
vendored
@ -17,6 +17,7 @@ type DeployKey struct {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
ReadOnly bool `json:"read_only"`
|
ReadOnly bool `json:"read_only"`
|
||||||
}
|
}
|
||||||
@ -33,18 +34,15 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error
|
|||||||
return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key)
|
return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateKeyOption options when create deploy key
|
// CreateKeyOption options when creating a key
|
||||||
// swagger:parameters userCurrentPostKey adminCreatePublicKey
|
|
||||||
type CreateKeyOption struct {
|
type CreateKeyOption struct {
|
||||||
// Title of the key to add
|
// Title of the key to add
|
||||||
//
|
//
|
||||||
// in: body
|
|
||||||
// required: true
|
// required: true
|
||||||
// unique: true
|
// unique: true
|
||||||
Title string `json:"title" binding:"Required"`
|
Title string `json:"title" binding:"Required"`
|
||||||
// An armored SSH key to add
|
// An armored SSH key to add
|
||||||
//
|
//
|
||||||
// in: body
|
|
||||||
// required: true
|
// required: true
|
||||||
// unique: true
|
// unique: true
|
||||||
Key string `json:"key" binding:"Required"`
|
Key string `json:"key" binding:"Required"`
|
||||||
|
3
vendor/code.gitea.io/sdk/gitea/repo_watch.go
generated
vendored
3
vendor/code.gitea.io/sdk/gitea/repo_watch.go
generated
vendored
@ -10,8 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WatchInfo represents a API watch status of one repository
|
// WatchInfo represents an API watch status of one repository
|
||||||
// swagger:response WatchInfo
|
|
||||||
type WatchInfo struct {
|
type WatchInfo struct {
|
||||||
Subscribed bool `json:"subscribed"`
|
Subscribed bool `json:"subscribed"`
|
||||||
Ignored bool `json:"ignored"`
|
Ignored bool `json:"ignored"`
|
||||||
|
2
vendor/code.gitea.io/sdk/gitea/status.go
generated
vendored
2
vendor/code.gitea.io/sdk/gitea/status.go
generated
vendored
@ -37,7 +37,9 @@ type Status struct {
|
|||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Context string `json:"context"`
|
Context string `json:"context"`
|
||||||
Creator *User `json:"creator"`
|
Creator *User `json:"creator"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
vendor/code.gitea.io/sdk/gitea/user.go
generated
vendored
13
vendor/code.gitea.io/sdk/gitea/user.go
generated
vendored
@ -9,20 +9,21 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User represents a API user.
|
// User represents a user
|
||||||
// swagger:response User
|
// swagger:model
|
||||||
type User struct {
|
type User struct {
|
||||||
|
// the user's id
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
|
// the user's username
|
||||||
UserName string `json:"login"`
|
UserName string `json:"login"`
|
||||||
|
// the user's full name
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
|
// swagger:strfmt email
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
// URL to the user's avatar
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserList represents a list of API user.
|
|
||||||
// swagger:response UserList
|
|
||||||
type UserList []*User
|
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||||
func (u User) MarshalJSON() ([]byte, error) {
|
func (u User) MarshalJSON() ([]byte, error) {
|
||||||
// Re-declaring User to avoid recursion
|
// Re-declaring User to avoid recursion
|
||||||
|
14
vendor/code.gitea.io/sdk/gitea/user_email.go
generated
vendored
14
vendor/code.gitea.io/sdk/gitea/user_email.go
generated
vendored
@ -9,8 +9,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Email en email information of user
|
// Email an email address belonging to a user
|
||||||
type Email struct {
|
type Email struct {
|
||||||
|
// swagger:strfmt email
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Verified bool `json:"verified"`
|
Verified bool `json:"verified"`
|
||||||
Primary bool `json:"primary"`
|
Primary bool `json:"primary"`
|
||||||
@ -22,8 +23,9 @@ func (c *Client) ListEmails() ([]*Email, error) {
|
|||||||
return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
|
return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateEmailOption options when create an email
|
// CreateEmailOption options when creating email addresses
|
||||||
type CreateEmailOption struct {
|
type CreateEmailOption struct {
|
||||||
|
// email addresses to add
|
||||||
Emails []string `json:"emails"`
|
Emails []string `json:"emails"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +39,14 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) {
|
|||||||
return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails)
|
return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteEmailOption options when deleting email addresses
|
||||||
|
type DeleteEmailOption struct {
|
||||||
|
// email addresses to delete
|
||||||
|
Emails []string `json:"emails"`
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteEmail delete one email of current users'
|
// DeleteEmail delete one email of current users'
|
||||||
func (c *Client) DeleteEmail(opt CreateEmailOption) error {
|
func (c *Client) DeleteEmail(opt DeleteEmailOption) error {
|
||||||
body, err := json.Marshal(&opt)
|
body, err := json.Marshal(&opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
9
vendor/code.gitea.io/sdk/gitea/user_gpgkey.go
generated
vendored
9
vendor/code.gitea.io/sdk/gitea/user_gpgkey.go
generated
vendored
@ -11,12 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GPGKeyList represents a list of GPGKey
|
|
||||||
// swagger:response GPGKeyList
|
|
||||||
type GPGKeyList []*GPGKey
|
|
||||||
|
|
||||||
// GPGKey a user GPG key to sign commit and tag in repository
|
// GPGKey a user GPG key to sign commit and tag in repository
|
||||||
// swagger:response GPGKey
|
|
||||||
type GPGKey struct {
|
type GPGKey struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
PrimaryKeyID string `json:"primary_key_id"`
|
PrimaryKeyID string `json:"primary_key_id"`
|
||||||
@ -28,7 +23,9 @@ type GPGKey struct {
|
|||||||
CanEncryptComms bool `json:"can_encrypt_comms"`
|
CanEncryptComms bool `json:"can_encrypt_comms"`
|
||||||
CanEncryptStorage bool `json:"can_encrypt_storage"`
|
CanEncryptStorage bool `json:"can_encrypt_storage"`
|
||||||
CanCertify bool `json:"can_certify"`
|
CanCertify bool `json:"can_certify"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at,omitempty"`
|
Created time.Time `json:"created_at,omitempty"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Expires time.Time `json:"expires_at,omitempty"`
|
Expires time.Time `json:"expires_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +37,9 @@ type GPGKeyEmail struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateGPGKeyOption options create user GPG key
|
// CreateGPGKeyOption options create user GPG key
|
||||||
// swagger:parameters userCurrentPostGPGKey
|
|
||||||
type CreateGPGKeyOption struct {
|
type CreateGPGKeyOption struct {
|
||||||
// An armored GPG key to add
|
// An armored GPG key to add
|
||||||
//
|
//
|
||||||
// in: body
|
|
||||||
// required: true
|
// required: true
|
||||||
// unique: true
|
// unique: true
|
||||||
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
||||||
|
6
vendor/code.gitea.io/sdk/gitea/user_key.go
generated
vendored
6
vendor/code.gitea.io/sdk/gitea/user_key.go
generated
vendored
@ -11,17 +11,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PublicKeyList represents a list of PublicKey
|
|
||||||
// swagger:response PublicKeyList
|
|
||||||
type PublicKeyList []*PublicKey
|
|
||||||
|
|
||||||
// PublicKey publickey is a user key to push code to repository
|
// PublicKey publickey is a user key to push code to repository
|
||||||
// swagger:response PublicKey
|
|
||||||
type PublicKey struct {
|
type PublicKey struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
Title string `json:"title,omitempty"`
|
Title string `json:"title,omitempty"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at,omitempty"`
|
Created time.Time `json:"created_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@ -9,10 +9,10 @@
|
|||||||
"revisionTime": "2017-10-23T00:52:09Z"
|
"revisionTime": "2017-10-23T00:52:09Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Zgp5RqU+20L2p9TNl1rSsUIWEEE=",
|
"checksumSHA1": "OICEgmUefW4L4l/FK/NVFnl/aOM=",
|
||||||
"path": "code.gitea.io/sdk/gitea",
|
"path": "code.gitea.io/sdk/gitea",
|
||||||
"revision": "bc243ad6c268d60658c71185452334b300c268cf",
|
"revision": "1da52cf95ff3e7953227cfa0469e1c05a7d02557",
|
||||||
"revisionTime": "2017-08-21T08:23:17Z"
|
"revisionTime": "2017-11-12T09:10:33Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "bOODD4Gbw3GfcuQPU2dI40crxxk=",
|
"checksumSHA1": "bOODD4Gbw3GfcuQPU2dI40crxxk=",
|
||||||
|
Loading…
Reference in New Issue
Block a user