This repository has been archived by the owner on Apr 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgroup.go
60 lines (48 loc) · 1.53 KB
/
group.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
package stormpath
import "net/url"
//Group represents a Stormpath Group
//
//See: http://docs.stormpath.com/rest/product-guide/#groups
type Group struct {
Href string `json:"href,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
CustomData *link `json:"customData,omitempty"`
Accounts *link `json:"accounts,omitempty"`
Tenant *link `json:"tenant,omitempty"`
Directory *link `json:"directory,omitempty"`
}
//Groups represent a paged result of groups
type Groups struct {
list
Items []Groups `json:"items"`
}
//NewGroup creates a new Group with the given name
func NewGroup(name string) *Group {
return &Group{Name: name}
}
func (group *Group) Save() error {
return client.post(group.Href, group, group)
}
func (group *Group) Delete() error {
return client.delete(group.Href, emptyPayload())
}
func (group *Group) GetAccounts(pageRequest url.Values, filter url.Values) (*Accounts, error) {
accounts := &Accounts{}
err := client.get(
buildAbsoluteURL(group.Accounts.Href, requestParams(pageRequest, filter, url.Values{})),
emptyPayload(),
accounts,
)
return accounts, err
}
func (group *Group) GetGroupMemberships(pageRequest url.Values, filter url.Values) (*GroupMemberships, error) {
groupMemberships := &GroupMemberships{}
err := client.get(
buildAbsoluteURL(group.Href, "accountMemberships", requestParams(pageRequest, filter, url.Values{})),
emptyPayload(),
groupMemberships,
)
return groupMemberships, err
}