mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
updated client routes
This commit is contained in:
parent
21f9aec808
commit
e5cc46b4dd
4 changed files with 30 additions and 31 deletions
|
@ -11,17 +11,17 @@ type CommitService struct {
|
|||
*Client
|
||||
}
|
||||
|
||||
// GET /v1/repos/{host}/{owner}/{name}/branch/{branch}/commit/{commit}
|
||||
// GET /api/repos/{host}/{owner}/{name}/branch/{branch}/commit/{commit}
|
||||
func (s *CommitService) Get(host, owner, name, branch, sha string) (*model.Commit, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s/branches/%s/commits/%s", host, owner, name, branch, sha)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s/branches/%s/commits/%s", host, owner, name, branch, sha)
|
||||
var commit = model.Commit{}
|
||||
var err = s.run("GET", path, nil, &commit)
|
||||
return &commit, err
|
||||
}
|
||||
|
||||
// GET /v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}/console
|
||||
// GET /api/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}/console
|
||||
func (s *CommitService) GetOutput(host, owner, name, branch, sha string) (io.ReadCloser, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s/branches/%s/commits/%s/console", host, owner, name, branch, sha)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s/branches/%s/commits/%s/console", host, owner, name, branch, sha)
|
||||
resp, err := s.do("GET", path)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
|
@ -29,23 +29,23 @@ func (s *CommitService) GetOutput(host, owner, name, branch, sha string) (io.Rea
|
|||
return resp.Body, nil
|
||||
}
|
||||
|
||||
// POST /v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}?action=rebuild
|
||||
// POST /api/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}?action=rebuild
|
||||
func (s *CommitService) Rebuild(host, owner, name, branch, sha string) error {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s/branches/%s/commits/%s?action=rebuild", host, owner, name, branch, sha)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s/branches/%s/commits/%s?action=rebuild", host, owner, name, branch, sha)
|
||||
return s.run("POST", path, nil, nil)
|
||||
}
|
||||
|
||||
// GET /v1/repos/{host}/{owner}/{name}/feed
|
||||
// GET /api/repos/{host}/{owner}/{name}/feed
|
||||
func (s *CommitService) List(host, owner, name string) ([]*model.Commit, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s/feed", host, owner, name)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s/feed", host, owner, name)
|
||||
var list []*model.Commit
|
||||
var err = s.run("GET", path, nil, &list)
|
||||
return list, err
|
||||
}
|
||||
|
||||
// GET /v1/repos/{host}/{owner}/{name}/branch/{branch}
|
||||
// GET /api/repos/{host}/{owner}/{name}/branch/{branch}
|
||||
func (s *CommitService) ListBranch(host, owner, name, branch string) ([]*model.Commit, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s/branches/%s/commits", host, owner, name, branch)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s/branches/%s/commits", host, owner, name, branch)
|
||||
var list []*model.Commit
|
||||
var err = s.run("GET", path, nil, &list)
|
||||
return list, err
|
||||
|
|
|
@ -10,37 +10,37 @@ type RepoService struct {
|
|||
*Client
|
||||
}
|
||||
|
||||
// GET /v1/repos/{host}/{owner}/{name}
|
||||
// GET /api/repos/{host}/{owner}/{name}
|
||||
func (s *RepoService) Get(host, owner, name string) (*model.Repo, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s", host, owner, name)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s", host, owner, name)
|
||||
var repo = model.Repo{}
|
||||
var err = s.run("PUT", path, nil, &repo)
|
||||
return &repo, err
|
||||
}
|
||||
|
||||
// PUT /v1/repos/{host}/{owner}/{name}
|
||||
// PUT /api/repos/{host}/{owner}/{name}
|
||||
func (s *RepoService) Update(repo *model.Repo) (*model.Repo, error) {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s", repo.Host, repo.Owner, repo.Name)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s", repo.Host, repo.Owner, repo.Name)
|
||||
var result = model.Repo{}
|
||||
var err = s.run("PUT", path, &repo, &result)
|
||||
return &result, err
|
||||
}
|
||||
|
||||
// POST /v1/repos/{host}/{owner}/{name}
|
||||
// POST /api/repos/{host}/{owner}/{name}
|
||||
func (s *RepoService) Enable(host, owner, name string) error {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s", host, owner, name)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s", host, owner, name)
|
||||
return s.run("POST", path, nil, nil)
|
||||
}
|
||||
|
||||
// DELETE /v1/repos/{host}/{owner}/{name}
|
||||
// DELETE /api/repos/{host}/{owner}/{name}
|
||||
func (s *RepoService) Disable(host, owner, name string) error {
|
||||
var path = fmt.Sprintf("/v1/repos/%s/%s/%s", host, owner, name)
|
||||
var path = fmt.Sprintf("/api/repos/%s/%s/%s", host, owner, name)
|
||||
return s.run("DELETE", path, nil, nil)
|
||||
}
|
||||
|
||||
// GET /v1/user/repos
|
||||
// GET /api/user/repos
|
||||
func (s *RepoService) List() ([]*model.Repo, error) {
|
||||
var repos []*model.Repo
|
||||
var err = s.run("GET", "/v1/user/repos", nil, &repos)
|
||||
var err = s.run("GET", "/api/user/repos", nil, &repos)
|
||||
return repos, err
|
||||
}
|
||||
|
|
|
@ -10,38 +10,38 @@ type UserService struct {
|
|||
*Client
|
||||
}
|
||||
|
||||
// GET /v1/users/{host}/{login}
|
||||
// GET /api/users/{host}/{login}
|
||||
func (s *UserService) Get(remote, login string) (*model.User, error) {
|
||||
var path = fmt.Sprintf("/v1/users/%s/%s", remote, login)
|
||||
var path = fmt.Sprintf("/api/users/%s/%s", remote, login)
|
||||
var user = model.User{}
|
||||
var err = s.run("GET", path, nil, &user)
|
||||
return &user, err
|
||||
}
|
||||
|
||||
// GET /v1/user
|
||||
// GET /api/user
|
||||
func (s *UserService) GetCurrent() (*model.User, error) {
|
||||
var user = model.User{}
|
||||
var err = s.run("GET", "/v1/user", nil, &user)
|
||||
var err = s.run("GET", "/api/user", nil, &user)
|
||||
return &user, err
|
||||
}
|
||||
|
||||
// POST /v1/users/{host}/{login}
|
||||
// POST /api/users/{host}/{login}
|
||||
func (s *UserService) Create(remote, login string) (*model.User, error) {
|
||||
var path = fmt.Sprintf("/v1/users/%s/%s", remote, login)
|
||||
var path = fmt.Sprintf("/api/users/%s/%s", remote, login)
|
||||
var user = model.User{}
|
||||
var err = s.run("POST", path, nil, &user)
|
||||
return &user, err
|
||||
}
|
||||
|
||||
// DELETE /v1/users/{host}/{login}
|
||||
// DELETE /api/users/{host}/{login}
|
||||
func (s *UserService) Delete(remote, login string) error {
|
||||
var path = fmt.Sprintf("/v1/users/%s/%s", remote, login)
|
||||
var path = fmt.Sprintf("/api/users/%s/%s", remote, login)
|
||||
return s.run("DELETE", path, nil, nil)
|
||||
}
|
||||
|
||||
// GET /v1/users
|
||||
// GET /api/users
|
||||
func (s *UserService) List() ([]*model.User, error) {
|
||||
var users []*model.User
|
||||
var err = s.run("GET", "/v1/users", nil, &users)
|
||||
var err = s.run("GET", "/api/users", nil, &users)
|
||||
return users, err
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/drone/drone/server/datastore"
|
||||
|
|
Loading…
Reference in a new issue