1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/client/repos.go

47 lines
1.2 KiB
Go
Raw Normal View History

2014-08-10 02:51:08 +03:00
package client
import (
"fmt"
"github.com/drone/drone/shared/model"
)
type RepoService struct {
*Client
}
// GET /v1/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)
2014-08-10 02:51:08 +03:00
var repo = model.Repo{}
var err = s.run("PUT", path, nil, &repo)
return &repo, err
}
// PUT /v1/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)
2014-08-10 02:51:08 +03:00
var result = model.Repo{}
var err = s.run("PUT", path, &repo, &result)
return &result, err
}
// POST /v1/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)
return s.run("POST", path, nil, nil)
}
// DELETE /v1/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)
return s.run("DELETE", path, nil, nil)
}
// GET /v1/user/repos
func (s *RepoService) List() ([]*model.Repo, error) {
var repos []*model.Repo
var err = s.run("GET", "/v1/user/repos", nil, &repos)
return repos, err
}