forked from ktrysmt/go-bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathteams.go
65 lines (52 loc) · 1.97 KB
/
teams.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package bitbucket
type Teams struct {
c *Client
}
func (t *Teams) List(role string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/?role=%s", role)
return t.c.execute("GET", urlStr, "")
}
func (t *Teams) Profile(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/", teamname)
return t.c.execute("GET", urlStr, "")
}
func (t *Teams) Members(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/members", teamname)
return t.c.execute("GET", urlStr, "")
}
func (t *Teams) Followers(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/followers", teamname)
return t.c.execute("GET", urlStr, "")
}
func (t *Teams) Following(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/following", teamname)
return t.c.execute("GET", urlStr, "")
}
func (t *Teams) Repositories(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/repositories", teamname)
return t.c.execute("GET", urlStr, "")
}
// Projects returns a list of project objects for the given team.
func (t *Teams) Projects(teamname string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/projects/", teamname)
return t.c.execute("GET", urlStr, "")
}
// ProjectNames returns a list of project names for the given team.
func (t *Teams) ProjectNames(teamname string) ([]string, error) {
urlStr := t.c.requestUrl("/teams/%s/projects/", teamname)
response, err := t.c.execute("GET", urlStr, "")
if err != nil {
return nil, err
}
list := response.(map[string]interface{})["values"].([]interface{})
projects := make([]string, len(list))
for i, l := range list {
projects[i] = l.(map[string]interface{})["name"].(string)
}
return projects, nil
}
// ProjectInfo return information on a specific project
func (t *Teams) ProjectInfo(teamname, projectKey string) (interface{}, error) {
urlStr := t.c.requestUrl("/teams/%s/projects/%s", teamname, projectKey)
return t.c.execute("GET", urlStr, "")
}