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
/
account_criteria.go
135 lines (110 loc) · 3.92 KB
/
account_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package stormpath
import (
"fmt"
"net/url"
)
//AccountCriteria represents the Criteria type for accounts
type AccountCriteria struct {
baseCriteria
}
//MakeAccountCriteria creates a new AccountCriteria for a single Account resource
func MakeAccountCriteria() AccountCriteria {
return AccountCriteria{baseCriteria{filter: url.Values{}}}
}
//MakeAccountsCriteria creates a new AccountCriteria for a AccountList resource
func MakeAccountsCriteria() AccountCriteria {
return AccountCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Pagination
func (c AccountCriteria) Limit(limit int) AccountCriteria {
c.limit = limit
return c
}
func (c AccountCriteria) Offset(offset int) AccountCriteria {
c.offset = offset
return c
}
//Filter related functions
//Possible filters:
//* givenName
//* surname
//* email
//* username
//* middleName
//* status
//* customData
//GivenNameEq adds the givenName equal filter to the given AccountCriteria
func (c AccountCriteria) GivenNameEq(givenName string) AccountCriteria {
c.filter.Add("givenName", givenName)
return c
}
//SurnameEq adds the surname equals filter to the given AccountCriteria
func (c AccountCriteria) SurnameEq(surname string) AccountCriteria {
c.filter.Add("surname", surname)
return c
}
//EmailEq adds the email equals filter to the given AccountCriteria
func (c AccountCriteria) EmailEq(email string) AccountCriteria {
c.filter.Add("email", email)
return c
}
//UsernameEq adds the username equals fitler to the given AccountCriteria
func (c AccountCriteria) UsernameEq(username string) AccountCriteria {
c.filter.Add("username", username)
return c
}
//MiddleNameEq adds the middleName equals filter to the given AccountCriteria
func (c AccountCriteria) MiddleNameEq(middleName string) AccountCriteria {
c.filter.Add("middleName", middleName)
return c
}
//StatusEq adds the status equals filter to the given AccountCriteria
func (c AccountCriteria) StatusEq(status string) AccountCriteria {
c.filter.Add("status", status)
return c
}
func (c AccountCriteria) CustomDataEq(k string, v string) AccountCriteria {
c.filter.Add(fmt.Sprintf("customData.%s", k), v)
return c
}
//Expansion related functions
//WithDirectory adds the directory expansion to the given AccountCriteria
func (c AccountCriteria) WithDirectory() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "directory")
return c
}
//WithCustomData adds the customData expansion to the given AccountCriteria
func (c AccountCriteria) WithCustomData() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "customData")
return c
}
//WithTenant adds the tenant expansion to the given AccountCriteria
func (c AccountCriteria) WithTenant() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "tenant")
return c
}
//WithGroups adds the groups expansion to the given AccountCriteria
func (c AccountCriteria) WithGroups(pageRequest PageRequest) AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("groups"))
return c
}
//WithGroupMemberships adds the groupMembership expansion to the given AccountCriteria
func (c AccountCriteria) WithGroupMemberships(pageRequest PageRequest) AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("groupMemberships"))
return c
}
//WithProviderData adds the providerData expansion to the given AccountCriteria
func (c AccountCriteria) WithProviderData() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "providerData")
return c
}
//WithAPIKeys adds the apiKeys expansion to the given AccountCriteria
func (c AccountCriteria) WithAPIKeys() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "apiKeys")
return c
}
//WithApplications adds the applications expansion to the given AccountCriteria
func (c AccountCriteria) WithApplications() AccountCriteria {
c.expandedAttributes = append(c.expandedAttributes, "applications")
return c
}