This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
collaborator.go
89 lines (76 loc) · 2.86 KB
/
collaborator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// A collaborator represents an account that has been given access to an app on
// Heroku.
type Collaborator struct {
// when collaborator was created
CreatedAt time.Time `json:"created_at"`
// unique identifier of collaborator
Id string `json:"id"`
// when collaborator was updated
UpdatedAt time.Time `json:"updated_at"`
// identity of collaborated account
User struct {
Email string `json:"email"`
Id string `json:"id"`
} `json:"user"`
}
// Create a new collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App. user is the
// unique email address of account or unique identifier of an account. options
// is the struct of optional parameters for this action.
func (c *Client) CollaboratorCreate(appIdentity string, user string, options *CollaboratorCreateOpts) (*Collaborator, error) {
params := struct {
User string `json:"user"`
Silent *bool `json:"silent,omitempty"`
}{
User: user,
}
if options != nil {
params.Silent = options.Silent
}
var collaboratorRes Collaborator
return &collaboratorRes, c.Post(&collaboratorRes, "/apps/"+appIdentity+"/collaborators", params)
}
// CollaboratorCreateOpts holds the optional parameters for CollaboratorCreate
type CollaboratorCreateOpts struct {
// whether to suppress email invitation when creating collaborator
Silent *bool `json:"silent,omitempty"`
}
// Delete an existing collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App.
// collaboratorIdentity is the unique identifier of the Collaborator.
func (c *Client) CollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
}
// Info for existing collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App.
// collaboratorIdentity is the unique identifier of the Collaborator.
func (c *Client) CollaboratorInfo(appIdentity string, collaboratorIdentity string) (*Collaborator, error) {
var collaborator Collaborator
return &collaborator, c.Get(&collaborator, "/apps/"+appIdentity+"/collaborators/"+collaboratorIdentity)
}
// List existing collaborators.
//
// appIdentity is the unique identifier of the Collaborator's App. lr is an
// optional ListRange that sets the Range options for the paginated list of
// results.
func (c *Client) CollaboratorList(appIdentity string, lr *ListRange) ([]Collaborator, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/collaborators", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var collaboratorsRes []Collaborator
return collaboratorsRes, c.DoReq(req, &collaboratorsRes)
}