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
/
group_criteria.go
71 lines (54 loc) · 1.48 KB
/
group_criteria.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
package stormpath
import "net/url"
type GroupCriteria struct {
baseCriteria
}
func MakeGroupCriteria() GroupCriteria {
return GroupCriteria{baseCriteria{filter: url.Values{}}}
}
func MakeGroupsCriteria() GroupCriteria {
return GroupCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Pagination
func (c GroupCriteria) Limit(limit int) GroupCriteria {
c.limit = limit
return c
}
func (c GroupCriteria) Offset(offset int) GroupCriteria {
c.offset = offset
return c
}
//Filter related functions
//Possible filters:
//* name
//* description
//* status
func (c GroupCriteria) NameEq(name string) GroupCriteria {
c.filter.Add(Name, name)
return c
}
func (c GroupCriteria) DescriptionEq(description string) GroupCriteria {
c.filter.Add(Description, description)
return c
}
func (c GroupCriteria) StatusEq(status string) GroupCriteria {
c.filter.Add(Status, status)
return c
}
//Expansion related functions
func (c GroupCriteria) WithCustomData() GroupCriteria {
c.expandedAttributes = append(c.expandedAttributes, "customData")
return c
}
func (c GroupCriteria) WithAccounts(pageRequest PageRequest) GroupCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accounts"))
return c
}
func (c GroupCriteria) WithTenant() GroupCriteria {
c.expandedAttributes = append(c.expandedAttributes, "tenant")
return c
}
func (c GroupCriteria) WithDirectory() GroupCriteria {
c.expandedAttributes = append(c.expandedAttributes, "directory")
return c
}