mirror of
https://github.com/harness/drone.git
synced 2025-05-07 00:32:56 +08:00
updated client routes
This commit is contained in:
parent
21f9aec808
commit
e5cc46b4dd
@ -11,17 +11,17 @@ type CommitService struct {
|
|||||||
*Client
|
*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) {
|
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 commit = model.Commit{}
|
||||||
var err = s.run("GET", path, nil, &commit)
|
var err = s.run("GET", path, nil, &commit)
|
||||||
return &commit, err
|
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) {
|
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)
|
resp, err := s.do("GET", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -29,23 +29,23 @@ func (s *CommitService) GetOutput(host, owner, name, branch, sha string) (io.Rea
|
|||||||
return resp.Body, nil
|
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 {
|
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)
|
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) {
|
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 list []*model.Commit
|
||||||
var err = s.run("GET", path, nil, &list)
|
var err = s.run("GET", path, nil, &list)
|
||||||
return list, err
|
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) {
|
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 list []*model.Commit
|
||||||
var err = s.run("GET", path, nil, &list)
|
var err = s.run("GET", path, nil, &list)
|
||||||
return list, err
|
return list, err
|
||||||
|
@ -10,37 +10,37 @@ type RepoService struct {
|
|||||||
*Client
|
*Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /v1/repos/{host}/{owner}/{name}
|
// GET /api/repos/{host}/{owner}/{name}
|
||||||
func (s *RepoService) Get(host, owner, name string) (*model.Repo, error) {
|
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 repo = model.Repo{}
|
||||||
var err = s.run("PUT", path, nil, &repo)
|
var err = s.run("PUT", path, nil, &repo)
|
||||||
return &repo, err
|
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) {
|
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 result = model.Repo{}
|
||||||
var err = s.run("PUT", path, &repo, &result)
|
var err = s.run("PUT", path, &repo, &result)
|
||||||
return &result, err
|
return &result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /v1/repos/{host}/{owner}/{name}
|
// POST /api/repos/{host}/{owner}/{name}
|
||||||
func (s *RepoService) Enable(host, owner, name string) error {
|
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)
|
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 {
|
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)
|
return s.run("DELETE", path, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /v1/user/repos
|
// GET /api/user/repos
|
||||||
func (s *RepoService) List() ([]*model.Repo, error) {
|
func (s *RepoService) List() ([]*model.Repo, error) {
|
||||||
var repos []*model.Repo
|
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
|
return repos, err
|
||||||
}
|
}
|
||||||
|
@ -10,38 +10,38 @@ type UserService struct {
|
|||||||
*Client
|
*Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /v1/users/{host}/{login}
|
// GET /api/users/{host}/{login}
|
||||||
func (s *UserService) Get(remote, login string) (*model.User, error) {
|
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 user = model.User{}
|
||||||
var err = s.run("GET", path, nil, &user)
|
var err = s.run("GET", path, nil, &user)
|
||||||
return &user, err
|
return &user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /v1/user
|
// GET /api/user
|
||||||
func (s *UserService) GetCurrent() (*model.User, error) {
|
func (s *UserService) GetCurrent() (*model.User, error) {
|
||||||
var user = model.User{}
|
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
|
return &user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /v1/users/{host}/{login}
|
// POST /api/users/{host}/{login}
|
||||||
func (s *UserService) Create(remote, login string) (*model.User, error) {
|
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 user = model.User{}
|
||||||
var err = s.run("POST", path, nil, &user)
|
var err = s.run("POST", path, nil, &user)
|
||||||
return &user, err
|
return &user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE /v1/users/{host}/{login}
|
// DELETE /api/users/{host}/{login}
|
||||||
func (s *UserService) Delete(remote, login string) error {
|
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)
|
return s.run("DELETE", path, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /v1/users
|
// GET /api/users
|
||||||
func (s *UserService) List() ([]*model.User, error) {
|
func (s *UserService) List() ([]*model.User, error) {
|
||||||
var users []*model.User
|
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
|
return users, err
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/drone/drone/server/datastore"
|
"github.com/drone/drone/server/datastore"
|
||||||
|
Loading…
Reference in New Issue
Block a user