forked from Scalingo/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collaborators.go
42 lines (35 loc) · 1.11 KB
/
collaborators.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
package api
import "github.com/Scalingo/cli/Godeps/_workspace/src/gopkg.in/errgo.v1"
type Collaborator struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Status string `json:"status"`
}
type CollaboratorsRes struct {
Collaborators []Collaborator `json:"collaborators"`
}
type CollaboratorRes struct {
Collaborator Collaborator `json:"collaborator"`
}
func CollaboratorsList(app string) ([]Collaborator, error) {
var collaboratorsRes CollaboratorsRes
err := subresourceList(app, "collaborators", nil, &collaboratorsRes)
if err != nil {
return nil, errgo.Mask(err)
}
return collaboratorsRes.Collaborators, nil
}
func CollaboratorAdd(app string, email string) (Collaborator, error) {
var collaboratorRes CollaboratorRes
err := subresourceAdd(app, "collaborators", CollaboratorRes{
Collaborator: Collaborator{Email: email},
}, &collaboratorRes)
if err != nil {
return Collaborator{}, errgo.Mask(err)
}
return collaboratorRes.Collaborator, nil
}
func CollaboratorRemove(app string, id string) error {
return subresourceDelete(app, "collaborators", id)
}