-
Notifications
You must be signed in to change notification settings - Fork 142
/
query.go
320 lines (308 loc) · 7.79 KB
/
query.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*
* Copyright 2018 - Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY
package query
import (
"net/url"
"strconv"
)
type Params struct {
Q string `json:"q,omitempty"`
After string `json:"after,omitempty"`
Limit int64 `json:"limit,omitempty"`
Filter string `json:"filter,omitempty"`
Expand string `json:"expand,omitempty"`
IncludeNonDeleted *bool `json:"includeNonDeleted,omitempty"`
Activate *bool `json:"activate,omitempty"`
TargetAid string `json:"targetAid,omitempty"`
QueryScope string `json:"query_scope,omitempty"`
SendEmail *bool `json:"sendEmail,omitempty"`
RemoveUsers *bool `json:"removeUsers,omitempty"`
ManagedBy string `json:"managedBy,omitempty"`
Until string `json:"until,omitempty"`
Since string `json:"since,omitempty"`
SortOrder string `json:"sortOrder,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
Format string `json:"format,omitempty"`
Search string `json:"search,omitempty"`
Provider string `json:"provider,omitempty"`
NextLogin string `json:"nextLogin,omitempty"`
Strict *bool `json:"strict,omitempty"`
ShowAll *bool `json:"showAll,omitempty"`
UpdatePhone *bool `json:"updatePhone,omitempty"`
TemplateId string `json:"templateId,omitempty"`
TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"`
TempPassword *bool `json:"tempPassword,omitempty"`
OauthTokens *bool `json:"oauthTokens,omitempty"`
}
func NewQueryParams(paramOpt ...ParamOptions) *Params {
p := &Params{}
for _, par := range paramOpt {
par(p)
}
return p
}
type ParamOptions func(*Params)
func WithQ(queryQ string) ParamOptions {
return func(p *Params) {
p.Q = queryQ
}
}
func WithAfter(queryAfter string) ParamOptions {
return func(p *Params) {
p.After = queryAfter
}
}
func WithLimit(queryLimit int64) ParamOptions {
return func(p *Params) {
p.Limit = queryLimit
}
}
func WithFilter(queryFilter string) ParamOptions {
return func(p *Params) {
p.Filter = queryFilter
}
}
func WithExpand(queryExpand string) ParamOptions {
return func(p *Params) {
p.Expand = queryExpand
}
}
func WithIncludeNonDeleted(queryIncludeNonDeleted bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryIncludeNonDeleted
p.IncludeNonDeleted = b
}
}
func WithActivate(queryActivate bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryActivate
p.Activate = b
}
}
func WithTargetAid(queryTargetAid string) ParamOptions {
return func(p *Params) {
p.TargetAid = queryTargetAid
}
}
func WithQueryScope(queryQueryScope string) ParamOptions {
return func(p *Params) {
p.QueryScope = queryQueryScope
}
}
func WithSendEmail(querySendEmail bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = querySendEmail
p.SendEmail = b
}
}
func WithRemoveUsers(queryRemoveUsers bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryRemoveUsers
p.RemoveUsers = b
}
}
func WithManagedBy(queryManagedBy string) ParamOptions {
return func(p *Params) {
p.ManagedBy = queryManagedBy
}
}
func WithUntil(queryUntil string) ParamOptions {
return func(p *Params) {
p.Until = queryUntil
}
}
func WithSince(querySince string) ParamOptions {
return func(p *Params) {
p.Since = querySince
}
}
func WithSortOrder(querySortOrder string) ParamOptions {
return func(p *Params) {
p.SortOrder = querySortOrder
}
}
func WithType(queryType string) ParamOptions {
return func(p *Params) {
p.Type = queryType
}
}
func WithStatus(queryStatus string) ParamOptions {
return func(p *Params) {
p.Status = queryStatus
}
}
func WithFormat(queryFormat string) ParamOptions {
return func(p *Params) {
p.Format = queryFormat
}
}
func WithSearch(querySearch string) ParamOptions {
return func(p *Params) {
p.Search = querySearch
}
}
func WithProvider(queryProvider string) ParamOptions {
return func(p *Params) {
p.Provider = queryProvider
}
}
func WithNextLogin(queryNextLogin string) ParamOptions {
return func(p *Params) {
p.NextLogin = queryNextLogin
}
}
func WithStrict(queryStrict bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryStrict
p.Strict = b
}
}
func WithShowAll(queryShowAll bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryShowAll
p.ShowAll = b
}
}
func WithUpdatePhone(queryUpdatePhone bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryUpdatePhone
p.UpdatePhone = b
}
}
func WithTemplateId(queryTemplateId string) ParamOptions {
return func(p *Params) {
p.TemplateId = queryTemplateId
}
}
func WithTokenLifetimeSeconds(queryTokenLifetimeSeconds int64) ParamOptions {
return func(p *Params) {
p.TokenLifetimeSeconds = queryTokenLifetimeSeconds
}
}
func WithTempPassword(queryTempPassword bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryTempPassword
p.TempPassword = b
}
}
func WithOauthTokens(queryOauthTokens bool) ParamOptions {
return func(p *Params) {
b := new(bool)
*b = queryOauthTokens
p.OauthTokens = b
}
}
func (p *Params) String() string {
qs := url.Values{}
if p.Q != "" {
qs.Add(`q`, p.Q)
}
if p.After != "" {
qs.Add(`after`, p.After)
}
if p.Limit != 0 {
qs.Add(`limit`, strconv.FormatInt(p.Limit, 10))
}
if p.Filter != "" {
qs.Add(`filter`, p.Filter)
}
if p.Expand != "" {
qs.Add(`expand`, p.Expand)
}
if p.IncludeNonDeleted != nil {
qs.Add(`includeNonDeleted`, strconv.FormatBool(*p.IncludeNonDeleted))
}
if p.Activate != nil {
qs.Add(`activate`, strconv.FormatBool(*p.Activate))
}
if p.TargetAid != "" {
qs.Add(`targetAid`, p.TargetAid)
}
if p.QueryScope != "" {
qs.Add(`query_scope`, p.QueryScope)
}
if p.SendEmail != nil {
qs.Add(`sendEmail`, strconv.FormatBool(*p.SendEmail))
}
if p.RemoveUsers != nil {
qs.Add(`removeUsers`, strconv.FormatBool(*p.RemoveUsers))
}
if p.ManagedBy != "" {
qs.Add(`managedBy`, p.ManagedBy)
}
if p.Until != "" {
qs.Add(`until`, p.Until)
}
if p.Since != "" {
qs.Add(`since`, p.Since)
}
if p.SortOrder != "" {
qs.Add(`sortOrder`, p.SortOrder)
}
if p.Type != "" {
qs.Add(`type`, p.Type)
}
if p.Status != "" {
qs.Add(`status`, p.Status)
}
if p.Format != "" {
qs.Add(`format`, p.Format)
}
if p.Search != "" {
qs.Add(`search`, p.Search)
}
if p.Provider != "" {
qs.Add(`provider`, p.Provider)
}
if p.NextLogin != "" {
qs.Add(`nextLogin`, p.NextLogin)
}
if p.Strict != nil {
qs.Add(`strict`, strconv.FormatBool(*p.Strict))
}
if p.ShowAll != nil {
qs.Add(`showAll`, strconv.FormatBool(*p.ShowAll))
}
if p.UpdatePhone != nil {
qs.Add(`updatePhone`, strconv.FormatBool(*p.UpdatePhone))
}
if p.TemplateId != "" {
qs.Add(`templateId`, p.TemplateId)
}
if p.TokenLifetimeSeconds != 0 {
qs.Add(`tokenLifetimeSeconds`, strconv.FormatInt(p.TokenLifetimeSeconds, 10))
}
if p.TempPassword != nil {
qs.Add(`tempPassword`, strconv.FormatBool(*p.TempPassword))
}
if p.OauthTokens != nil {
qs.Add(`oauthTokens`, strconv.FormatBool(*p.OauthTokens))
}
if len(qs) != 0 {
return "?" + qs.Encode()
}
return ""
}