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
/
application_criteria.go
111 lines (89 loc) · 3.85 KB
/
application_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
package stormpath
import "net/url"
//ApplicationCriteria rerpresents the criteria object for an application or an applications collection.
type ApplicationCriteria struct {
baseCriteria
}
//MakeApplicationCriteria an empty ApplicationCriteria for an application.
func MakeApplicationCriteria() ApplicationCriteria {
return ApplicationCriteria{baseCriteria{filter: url.Values{}}}
}
//MakeApplicationsCriteria an empty ApplicationCriteria for an applications collection.
func MakeApplicationsCriteria() ApplicationCriteria {
return ApplicationCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Pagination
func (c ApplicationCriteria) Limit(limit int) ApplicationCriteria {
c.limit = limit
return c
}
func (c ApplicationCriteria) Offset(offset int) ApplicationCriteria {
c.offset = offset
return c
}
//Filter related functions
//Possible filters:
//* name
//* description
//* status
//NameEq adds the name filter to the given ApplicationCriteria
func (c ApplicationCriteria) NameEq(name string) ApplicationCriteria {
c.filter.Add("name", name)
return c
}
//DescriptionEq adds the description filter to the given ApplicationCriteria
func (c ApplicationCriteria) DescriptionEq(description string) ApplicationCriteria {
c.filter.Add("description", description)
return c
}
//StatusEq adds the status filter to the given ApplicationCriteria
func (c ApplicationCriteria) StatusEq(status string) ApplicationCriteria {
c.filter.Add("status", status)
return c
}
//Expansion related functions
//WithCustomData adds the customData expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithCustomData() ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "customData")
return c
}
//WithAccounts adds the accounts expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithAccounts(pageRequest PageRequest) ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accounts"))
return c
}
//WithGroups adds the groups expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithGroups(pageRequest PageRequest) ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("groups"))
return c
}
//WithTenant adds the tenant expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithTenant() ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "tenant")
return c
}
//WithAccountStoreMappings adds the accountStoreMapping expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithAccountStoreMappings(pageRequest PageRequest) ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accountStoreMappings"))
return c
}
//WithDefaultAccountStoreMapping adds the defaultGroupStoreMapping expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithDefaultAccountStoreMapping() ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "defaultAccountStoreMapping")
return c
}
//WithDefaultGroupStoreMapping adds the defaultGroupStoreMapping expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithDefaultGroupStoreMapping() ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, "defaultGroupStoreMapping")
return c
}
//WithRefreshTokens adds the refreshTokens expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithRefreshTokens(pageRequest PageRequest) ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("refreshTokens"))
return c
}
//WithAccessTokens adds the accessTokens expansion to the given ApplicationCriteria
func (c ApplicationCriteria) WithAccessTokens(pageRequest PageRequest) ApplicationCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accessTokens"))
return c
}