forked from forgejo/forgejo
#1692 add organization APIs
This commit is contained in:
parent
6673dcb038
commit
9cd16c5b12
20 changed files with 204 additions and 55 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
to "github.com/gogits/gogs/routers/api/v1/utils"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
|
||||
|
@ -26,7 +26,7 @@ func ListHooks(ctx *middleware.Context) {
|
|||
|
||||
apiHooks := make([]*api.Hook, len(hooks))
|
||||
for i := range hooks {
|
||||
apiHooks[i] = to.ApiHook(ctx.Repo.RepoLink, hooks[i])
|
||||
apiHooks[i] = convert.ToApiHook(ctx.Repo.RepoLink, hooks[i])
|
||||
}
|
||||
|
||||
ctx.JSON(200, &apiHooks)
|
||||
|
@ -94,7 +94,7 @@ func CreateHook(ctx *middleware.Context, form api.CreateHookOption) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(201, to.ApiHook(ctx.Repo.RepoLink, w))
|
||||
ctx.JSON(201, convert.ToApiHook(ctx.Repo.RepoLink, w))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
||||
|
@ -104,7 +104,7 @@ func EditHook(ctx *middleware.Context, form api.EditHookOption) {
|
|||
if models.IsErrWebhookNotExist(err) {
|
||||
ctx.Error(404)
|
||||
} else {
|
||||
ctx.APIError(500, "GetWebhookById", err)
|
||||
ctx.APIError(500, "GetWebhookByID", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -161,5 +161,5 @@ func EditHook(ctx *middleware.Context, form api.EditHookOption) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, to.ApiHook(ctx.Repo.RepoLink, w))
|
||||
ctx.JSON(200, convert.ToApiHook(ctx.Repo.RepoLink, w))
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
to "github.com/gogits/gogs/routers/api/v1/utils"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
func composeDeployKeysAPILink(repoPath string) string {
|
||||
|
@ -34,7 +34,7 @@ func ListDeployKeys(ctx *middleware.Context) {
|
|||
ctx.APIError(500, "GetContent", err)
|
||||
return
|
||||
}
|
||||
apiKeys[i] = to.ApiDeployKey(apiLink, keys[i])
|
||||
apiKeys[i] = convert.ToApiDeployKey(apiLink, keys[i])
|
||||
}
|
||||
|
||||
ctx.JSON(200, &apiKeys)
|
||||
|
@ -58,7 +58,7 @@ func GetDeployKey(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
apiLink := composeDeployKeysAPILink(ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name)
|
||||
ctx.JSON(200, to.ApiDeployKey(apiLink, key))
|
||||
ctx.JSON(200, convert.ToApiDeployKey(apiLink, key))
|
||||
}
|
||||
|
||||
func HandleCheckKeyStringError(ctx *middleware.Context, err error) {
|
||||
|
@ -96,7 +96,7 @@ func CreateDeployKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
|||
|
||||
key.Content = content
|
||||
apiLink := composeDeployKeysAPILink(ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name)
|
||||
ctx.JSON(201, to.ApiDeployKey(apiLink, key))
|
||||
ctx.JSON(201, convert.ToApiDeployKey(apiLink, key))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
to "github.com/gogits/gogs/routers/api/v1/utils"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
|
||||
|
@ -97,12 +97,12 @@ func ListMyRepos(ctx *middleware.Context) {
|
|||
|
||||
repos := make([]*api.Repository, numOwnRepos+len(accessibleRepos))
|
||||
for i := range ownRepos {
|
||||
repos[i] = to.ApiRepository(ctx.User, ownRepos[i], api.Permission{true, true, true})
|
||||
repos[i] = convert.ToApiRepository(ctx.User, ownRepos[i], api.Permission{true, true, true})
|
||||
}
|
||||
i := numOwnRepos
|
||||
|
||||
for repo, access := range accessibleRepos {
|
||||
repos[i] = to.ApiRepository(repo.Owner, repo, api.Permission{
|
||||
repos[i] = convert.ToApiRepository(repo.Owner, repo, api.Permission{
|
||||
Admin: access >= models.ACCESS_MODE_ADMIN,
|
||||
Push: access >= models.ACCESS_MODE_WRITE,
|
||||
Pull: true,
|
||||
|
@ -139,7 +139,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(201, to.ApiRepository(owner, repo, api.Permission{true, true, true}))
|
||||
ctx.JSON(201, convert.ToApiRepository(owner, repo, api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create
|
||||
|
@ -239,7 +239,7 @@ func Migrate(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
|||
}
|
||||
|
||||
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
|
||||
ctx.JSON(201, to.ApiRepository(ctxUser, repo, api.Permission{true, true, true}))
|
||||
ctx.JSON(201, convert.ToApiRepository(ctxUser, repo, api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repository) {
|
||||
|
@ -273,7 +273,7 @@ func Get(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, to.ApiRepository(owner, repo, api.Permission{true, true, true}))
|
||||
ctx.JSON(200, convert.ToApiRepository(owner, repo, api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue