forked from ktrysmt/go-bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 1
/
repositories.go
47 lines (40 loc) · 1.34 KB
/
repositories.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package bitbucket
import (
"fmt"
"net/url"
)
//"github.com/k0kubun/pp"
type Repositories struct {
c *Client
PullRequests *PullRequests
Repository *Repository
Commits *Commits
Diff *Diff
BranchRestrictions *BranchRestrictions
Webhooks *Webhooks
repositories
}
func (r *Repositories) ListForAccount(ro *RepositoriesOptions) (interface{}, error) {
urlStr := r.c.requestUrl("/repositories/%s", ro.Owner)
if ro.Role != "" {
urlStr += "?role=" + ro.Role
}
return r.c.execute("GET", urlStr, "")
}
func (r *Repositories) ListForTeam(ro *RepositoriesOptions) (interface{}, error) {
urlStr := r.c.requestUrl("/repositories/%s", ro.Owner)
if ro.Role != "" {
urlStr += "?role=" + ro.Role
}
return r.c.execute("GET", urlStr, "")
}
func (r *Repositories) ListPublic() (interface{}, error) {
urlStr := r.c.requestUrl("/repositories/", "")
return r.c.execute("GET", urlStr, "")
}
// ListForProject returns a pagenated list of repositories for the given project
func (r *Repositories) ListForProject(ro *ProjectRepositoryOptions) (interface{}, error) {
values, _ := url.ParseQuery(fmt.Sprintf("q=project.key=\"%s\"&pagelen=%d&page=%d", ro.Project, ro.PageLength, ro.Page))
urlStr := r.c.requestUrl("/repositories/%s?%s", ro.Owner, values.Encode())
return r.c.execute("GET", urlStr, "")
}