Skip to content

Commit

Permalink
updated client routes
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Sep 29, 2014
1 parent 21f9aec commit e5cc46b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
20 changes: 10 additions & 10 deletions client/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,41 @@ 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
}
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
Expand Down
20 changes: 10 additions & 10 deletions client/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
20 changes: 10 additions & 10 deletions client/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion server/middleware/repo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package middleware

import (
"fmt"
"net/http"

"github.com/drone/drone/server/datastore"
Expand Down

0 comments on commit e5cc46b

Please sign in to comment.