|
|
|
@ -22,7 +22,7 @@ func teamAPIOut(keybasePath string, w TeamAPI) (TeamAPI, error) {
@@ -22,7 +22,7 @@ func teamAPIOut(keybasePath string, w TeamAPI) (TeamAPI, error) {
|
|
|
|
|
return r, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddUser adds members to a team by username
|
|
|
|
|
// AddUser adds a member to a team by username
|
|
|
|
|
func (t Team) AddUser(user, role string) (TeamAPI, error) { |
|
|
|
|
m := TeamAPI{ |
|
|
|
|
Params: &tParams{}, |
|
|
|
@ -37,7 +37,87 @@ func (t Team) AddUser(user, role string) (TeamAPI, error) {
@@ -37,7 +37,87 @@ func (t Team) AddUser(user, role string) (TeamAPI, error) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
r, err := teamAPIOut(t.keybase.Path, m) |
|
|
|
|
if err == nil { |
|
|
|
|
if err == nil && r.Error == nil { |
|
|
|
|
r, err = t.MemberList() |
|
|
|
|
} |
|
|
|
|
return r, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddReaders adds members to a team by username, and sets their roles to Reader
|
|
|
|
|
func (t Team) AddReaders(users ...string) (TeamAPI, error) { |
|
|
|
|
m := TeamAPI{ |
|
|
|
|
Params: &tParams{}, |
|
|
|
|
} |
|
|
|
|
m.Method = "add-members" |
|
|
|
|
m.Params.Options.Team = t.Name |
|
|
|
|
addUsers := []usernames{} |
|
|
|
|
for _, u := range users { |
|
|
|
|
addUsers = append(addUsers, usernames{Username: u, Role: "reader"}) |
|
|
|
|
} |
|
|
|
|
m.Params.Options.Usernames = addUsers |
|
|
|
|
|
|
|
|
|
r, err := teamAPIOut(t.keybase.Path, m) |
|
|
|
|
if err == nil && r.Error == nil { |
|
|
|
|
r, err = t.MemberList() |
|
|
|
|
} |
|
|
|
|
return r, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddWriters adds members to a team by username, and sets their roles to Writer
|
|
|
|
|
func (t Team) AddWriters(users ...string) (TeamAPI, error) { |
|
|
|
|
m := TeamAPI{ |
|
|
|
|
Params: &tParams{}, |
|
|
|
|
} |
|
|
|
|
m.Method = "add-members" |
|
|
|
|
m.Params.Options.Team = t.Name |
|
|
|
|
addUsers := []usernames{} |
|
|
|
|
for _, u := range users { |
|
|
|
|
addUsers = append(addUsers, usernames{Username: u, Role: "writer"}) |
|
|
|
|
} |
|
|
|
|
m.Params.Options.Usernames = addUsers |
|
|
|
|
|
|
|
|
|
r, err := teamAPIOut(t.keybase.Path, m) |
|
|
|
|
if err == nil && r.Error == nil { |
|
|
|
|
r, err = t.MemberList() |
|
|
|
|
} |
|
|
|
|
return r, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddAdmins adds members to a team by username, and sets their roles to Writer
|
|
|
|
|
func (t Team) AddAdmins(users ...string) (TeamAPI, error) { |
|
|
|
|
m := TeamAPI{ |
|
|
|
|
Params: &tParams{}, |
|
|
|
|
} |
|
|
|
|
m.Method = "add-members" |
|
|
|
|
m.Params.Options.Team = t.Name |
|
|
|
|
addUsers := []usernames{} |
|
|
|
|
for _, u := range users { |
|
|
|
|
addUsers = append(addUsers, usernames{Username: u, Role: "admin"}) |
|
|
|
|
} |
|
|
|
|
m.Params.Options.Usernames = addUsers |
|
|
|
|
|
|
|
|
|
r, err := teamAPIOut(t.keybase.Path, m) |
|
|
|
|
if err == nil && r.Error == nil { |
|
|
|
|
r, err = t.MemberList() |
|
|
|
|
} |
|
|
|
|
return r, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddOwners adds members to a team by username, and sets their roles to Writer
|
|
|
|
|
func (t Team) AddOwners(users ...string) (TeamAPI, error) { |
|
|
|
|
m := TeamAPI{ |
|
|
|
|
Params: &tParams{}, |
|
|
|
|
} |
|
|
|
|
m.Method = "add-members" |
|
|
|
|
m.Params.Options.Team = t.Name |
|
|
|
|
addUsers := []usernames{} |
|
|
|
|
for _, u := range users { |
|
|
|
|
addUsers = append(addUsers, usernames{Username: u, Role: "owner"}) |
|
|
|
|
} |
|
|
|
|
m.Params.Options.Usernames = addUsers |
|
|
|
|
|
|
|
|
|
r, err := teamAPIOut(t.keybase.Path, m) |
|
|
|
|
if err == nil && r.Error == nil { |
|
|
|
|
r, err = t.MemberList() |
|
|
|
|
} |
|
|
|
|
return r, err |
|
|
|
|