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
/
directory_criteria.go
88 lines (68 loc) · 2.07 KB
/
directory_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
package stormpath
import (
"net/url"
)
type DirectoryCriteria struct {
baseCriteria
}
func MakeDirectoryCriteria() DirectoryCriteria {
return DirectoryCriteria{baseCriteria{filter: url.Values{}}}
}
func MakeDirectoriesCriteria() DirectoryCriteria {
return DirectoryCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Pagination
func (c DirectoryCriteria) Limit(limit int) DirectoryCriteria {
c.limit = limit
return c
}
func (c DirectoryCriteria) Offset(offset int) DirectoryCriteria {
c.offset = offset
return c
}
//Filter related functions
//Possible filters:
//* name
//* description
//* status
func (c DirectoryCriteria) NameEq(name string) DirectoryCriteria {
c.filter.Add(Name, name)
return c
}
func (c DirectoryCriteria) DescriptionEq(description string) DirectoryCriteria {
c.filter.Add(Description, description)
return c
}
func (c DirectoryCriteria) StatusEq(status string) DirectoryCriteria {
c.filter.Add(Status, status)
return c
}
//Expansion related functions
func (c DirectoryCriteria) WithCustomData() DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, "customData")
return c
}
func (c DirectoryCriteria) WithAccounts(pageRequest PageRequest) DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("accounts"))
return c
}
func (c DirectoryCriteria) WithGroups(pageRequest PageRequest) DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, pageRequest.toExpansion("groups"))
return c
}
func (c DirectoryCriteria) WithTenant() DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, "tenant")
return c
}
func (c DirectoryCriteria) WithProvider() DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, "provider")
return c
}
func (c DirectoryCriteria) WithAccountCreationPolicy() DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, "accountCreationPolicy")
return c
}
func (c DirectoryCriteria) WithPasswordPolicy() DirectoryCriteria {
c.expandedAttributes = append(c.expandedAttributes, "passwordPolicy")
return c
}