forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_membership.go
49 lines (40 loc) · 1.04 KB
/
group_membership.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
package stormpath
type GroupMembership struct {
resource
Account *Account `json:"account"`
Group *Group `json:"group"`
}
type GroupMemberships struct {
collectionResource
Items []GroupMembership `json:"items,omitempty"`
}
func NewGroupMembership(accountHref string, groupHref string) *GroupMembership {
account := Account{}
account.Href = accountHref
group := Group{}
group.Href = groupHref
return &GroupMembership{
Account: &account,
Group: &group,
}
}
func (groupmembership *GroupMembership) GetAccount(criteria Criteria) (*Account, error) {
err := client.get(
buildAbsoluteURL(groupmembership.Account.Href, criteria.ToQueryString()),
groupmembership.Account,
)
if err != nil {
return nil, err
}
return groupmembership.Account, nil
}
func (groupmembership *GroupMembership) GetGroup(criteria Criteria) (*Group, error) {
err := client.get(
buildAbsoluteURL(groupmembership.Group.Href, criteria.ToQueryString()),
groupmembership.Group,
)
if err != nil {
return nil, err
}
return groupmembership.Group, nil
}