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
/
organization_criteria.go
91 lines (70 loc) · 2.38 KB
/
organization_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package stormpath
import "net/url"
type OrganizationCriteria struct {
baseCriteria
}
func MakeOrganizationCriteria() OrganizationCriteria {
return OrganizationCriteria{baseCriteria{filter: url.Values{}}}
}
func MakeOrganizationsCriteria() OrganizationCriteria {
return OrganizationCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Pagination
func (c OrganizationCriteria) Limit(limit int) OrganizationCriteria {
c.limit = limit
return c
}
func (c OrganizationCriteria) Offset(offset int) OrganizationCriteria {
c.offset = offset
return c
}
//Filter related functions
//Possible filters:
//* name
//* description
//* status
func (c OrganizationCriteria) NameEq(name string) OrganizationCriteria {
c.filter.Add("name", name)
return c
}
func (c OrganizationCriteria) DescriptionEq(description string) OrganizationCriteria {
c.filter.Add("description", description)
return c
}
func (c OrganizationCriteria) StatusEq(status string) OrganizationCriteria {
c.filter.Add("status", status)
return c
}
func (c OrganizationCriteria) NameKeyEq(status string) OrganizationCriteria {
c.filter.Add("nameKey", status)
return c
}
//Expansion related functions
func (c OrganizationCriteria) WithCustomData() OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "customData")
return c
}
func (c OrganizationCriteria) WithAccounts(pageRequest PageRequest) OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accounts"))
return c
}
func (c OrganizationCriteria) WithGroups(pageRequest PageRequest) OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("groups"))
return c
}
func (c OrganizationCriteria) WithTenant() OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "tenant")
return c
}
func (c OrganizationCriteria) WithAccountStoreMappings(pageRequest PageRequest) OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accountStoreMappings"))
return c
}
func (c OrganizationCriteria) WithDefaultAccountStoreMapping() OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "defaultAccountStoreMapping")
return c
}
func (c OrganizationCriteria) WithDefaultGroupStoreMapping() OrganizationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "defaultGroupStoreMapping")
return c
}