forked from harness/gitness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teams.go
49 lines (38 loc) · 1.11 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
package bitbucket
const (
TeamRoleAdmin = "admin"
TeamRoleCollab = "collaborator"
)
// Use this resource to manage privilege settings for a team account. Team
// accounts can grant groups account privileges as well as repository access.
// Groups with account privileges are those with can administer this account
// (admin rights) or can create repositories in this account (collaborator
// rights) checked.
//
// https://confluence.atlassian.com/display/BITBUCKET/privileges+Resource
type TeamResource struct {
client *Client
}
type Team struct {
// The team or individual account name.
Name string
// The group's slug.
Role string
}
// Gets the groups with account privileges defined for a team account.
func (r *TeamResource) List() ([]*Team, error) {
// we'll get the data in a key/value struct
data := struct {
Teams map[string]string
}{ }
data.Teams = map[string]string{}
teams := []*Team{}
if err := r.client.do("GET", "/user/privileges", nil, nil, &data); err != nil {
return nil, err
}
for k,v := range data.Teams {
team := &Team{ k, v }
teams = append(teams, team)
}
return teams, nil
}