forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group.go
54 lines (44 loc) · 1.26 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
package stormpath
import (
"time"
)
//Group represents a Stormpath Group
//
//See: http://docs.stormpath.com/rest/product-guide/#groups
type Group struct {
accountStoreResource
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
Tenant *Tenant `json:"tenant,omitempty"`
Directory *Directory `json:"directory,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
ModifiedAt time.Time `json:"modifiedAt,omitempty"`
}
//Groups represent a paged result of groups
type Groups struct {
collectionResource
Items []Group `json:"items"`
}
//NewGroup creates a new Group with the given name
func NewGroup(name string) *Group {
return &Group{Name: name}
}
func GetGroup(href string, criteria Criteria) (*Group, error) {
group := &Group{}
err := client.get(
buildAbsoluteURL(href, criteria.ToQueryString()),
emptyPayload(),
group,
)
return group, err
}
func (group *Group) GetGroupMemberships(criteria Criteria) (*GroupMemberships, error) {
groupMemberships := &GroupMemberships{}
err := client.get(
buildAbsoluteURL(group.Href, "accountMemberships", criteria.ToQueryString()),
emptyPayload(),
groupMemberships,
)
return groupMemberships, err
}