-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathRemoteUserIndicesPrivileges.java
More file actions
486 lines (418 loc) · 14.9 KB
/
RemoteUserIndicesPrivileges.java
File metadata and controls
486 lines (418 loc) · 14.9 KB
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you 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.
*/
package co.elastic.clients.elasticsearch.security;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
// typedef: security._types.RemoteUserIndicesPrivileges
/**
*
* @see <a href=
* "../doc-files/api-spec.html#security._types.RemoteUserIndicesPrivileges">API
* specification</a>
*/
@JsonpDeserializable
public class RemoteUserIndicesPrivileges implements JsonpSerializable {
private final List<String> clusters;
private final List<FieldSecurity> fieldSecurity;
private final List<String> names;
private final List<String> privileges;
private final List<IndicesPrivilegesQuery> query;
private final boolean allowRestrictedIndices;
// ---------------------------------------------------------------------------------------------
private RemoteUserIndicesPrivileges(Builder builder) {
this.clusters = ApiTypeHelper.unmodifiableRequired(builder.clusters, this, "clusters");
this.fieldSecurity = ApiTypeHelper.unmodifiable(builder.fieldSecurity);
this.names = ApiTypeHelper.unmodifiableRequired(builder.names, this, "names");
this.privileges = ApiTypeHelper.unmodifiableRequired(builder.privileges, this, "privileges");
this.query = ApiTypeHelper.unmodifiable(builder.query);
this.allowRestrictedIndices = ApiTypeHelper.requireNonNull(builder.allowRestrictedIndices, this,
"allowRestrictedIndices", false);
}
public static RemoteUserIndicesPrivileges of(Function<Builder, ObjectBuilder<RemoteUserIndicesPrivileges>> fn) {
return fn.apply(new Builder()).build();
}
/**
* Required - API name: {@code clusters}
*/
public final List<String> clusters() {
return this.clusters;
}
/**
* The document fields that the owners of the role have read access to.
* <p>
* API name: {@code field_security}
*/
public final List<FieldSecurity> fieldSecurity() {
return this.fieldSecurity;
}
/**
* Required - A list of indices (or index name patterns) to which the
* permissions in this entry apply.
* <p>
* API name: {@code names}
*/
public final List<String> names() {
return this.names;
}
/**
* Required - The index level privileges that owners of the role have on the
* specified indices.
* <p>
* API name: {@code privileges}
*/
public final List<String> privileges() {
return this.privileges;
}
/**
* Search queries that define the documents the user has access to. A document
* within the specified indices must match these queries for it to be accessible
* by the owners of the role.
* <p>
* API name: {@code query}
*/
public final List<IndicesPrivilegesQuery> query() {
return this.query;
}
/**
* Required - Set to <code>true</code> if using wildcard or regular expressions
* for patterns that cover restricted indices. Implicitly, restricted indices
* have limited privileges that can cause pattern tests to fail. If restricted
* indices are explicitly included in the <code>names</code> list, Elasticsearch
* checks privileges against these indices regardless of the value set for
* <code>allow_restricted_indices</code>.
* <p>
* API name: {@code allow_restricted_indices}
*/
public final boolean allowRestrictedIndices() {
return this.allowRestrictedIndices;
}
/**
* Serialize this object to JSON.
*/
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (ApiTypeHelper.isDefined(this.clusters)) {
generator.writeKey("clusters");
generator.writeStartArray();
for (String item0 : this.clusters) {
generator.write(item0);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.fieldSecurity)) {
generator.writeKey("field_security");
generator.writeStartArray();
for (FieldSecurity item0 : this.fieldSecurity) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.names)) {
generator.writeKey("names");
generator.writeStartArray();
for (String item0 : this.names) {
generator.write(item0);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.privileges)) {
generator.writeKey("privileges");
generator.writeStartArray();
for (String item0 : this.privileges) {
generator.write(item0);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.query)) {
generator.writeKey("query");
generator.writeStartArray();
for (IndicesPrivilegesQuery item0 : this.query) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
generator.writeKey("allow_restricted_indices");
generator.write(this.allowRestrictedIndices);
}
@Override
public String toString() {
return JsonpUtils.toString(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link RemoteUserIndicesPrivileges}.
*/
public static class Builder extends WithJsonObjectBuilderBase<Builder>
implements
ObjectBuilder<RemoteUserIndicesPrivileges> {
private List<String> clusters;
@Nullable
private List<FieldSecurity> fieldSecurity;
private List<String> names;
private List<String> privileges;
@Nullable
private List<IndicesPrivilegesQuery> query;
private Boolean allowRestrictedIndices;
public Builder() {
}
private Builder(RemoteUserIndicesPrivileges instance) {
this.clusters = instance.clusters;
this.fieldSecurity = instance.fieldSecurity;
this.names = instance.names;
this.privileges = instance.privileges;
this.query = instance.query;
this.allowRestrictedIndices = instance.allowRestrictedIndices;
}
/**
* Required - API name: {@code clusters}
* <p>
* Adds all elements of <code>list</code> to <code>clusters</code>.
*/
public final Builder clusters(List<String> list) {
this.clusters = _listAddAll(this.clusters, list);
return this;
}
/**
* Required - API name: {@code clusters}
* <p>
* Adds one or more values to <code>clusters</code>.
*/
public final Builder clusters(String value, String... values) {
this.clusters = _listAdd(this.clusters, value, values);
return this;
}
/**
* The document fields that the owners of the role have read access to.
* <p>
* API name: {@code field_security}
* <p>
* Adds all elements of <code>list</code> to <code>fieldSecurity</code>.
*/
public final Builder fieldSecurity(List<FieldSecurity> list) {
this.fieldSecurity = _listAddAll(this.fieldSecurity, list);
return this;
}
/**
* The document fields that the owners of the role have read access to.
* <p>
* API name: {@code field_security}
* <p>
* Adds one or more values to <code>fieldSecurity</code>.
*/
public final Builder fieldSecurity(FieldSecurity value, FieldSecurity... values) {
this.fieldSecurity = _listAdd(this.fieldSecurity, value, values);
return this;
}
/**
* The document fields that the owners of the role have read access to.
* <p>
* API name: {@code field_security}
* <p>
* Adds a value to <code>fieldSecurity</code> using a builder lambda.
*/
public final Builder fieldSecurity(Function<FieldSecurity.Builder, ObjectBuilder<FieldSecurity>> fn) {
return fieldSecurity(fn.apply(new FieldSecurity.Builder()).build());
}
/**
* Required - A list of indices (or index name patterns) to which the
* permissions in this entry apply.
* <p>
* API name: {@code names}
* <p>
* Adds all elements of <code>list</code> to <code>names</code>.
*/
public final Builder names(List<String> list) {
this.names = _listAddAll(this.names, list);
return this;
}
/**
* Required - A list of indices (or index name patterns) to which the
* permissions in this entry apply.
* <p>
* API name: {@code names}
* <p>
* Adds one or more values to <code>names</code>.
*/
public final Builder names(String value, String... values) {
this.names = _listAdd(this.names, value, values);
return this;
}
/**
* Required - The index level privileges that owners of the role have on the
* specified indices.
* <p>
* API name: {@code privileges}
* <p>
* Adds all elements of <code>list</code> to <code>privileges</code>.
*/
public final Builder privileges(List<String> list) {
this.privileges = _listAddAll(this.privileges, list);
return this;
}
/**
* Required - The index level privileges that owners of the role have on the
* specified indices.
* <p>
* API name: {@code privileges}
* <p>
* Adds one or more values to <code>privileges</code>.
*/
public final Builder privileges(String value, String... values) {
this.privileges = _listAdd(this.privileges, value, values);
return this;
}
/**
* Required - The index level privileges that owners of the role have on the
* specified indices.
* <p>
* API name: {@code privileges}
* <p>
* Adds one or more enum values to <code>privileges</code>.
*/
public final Builder privileges(IndexPrivilege value, IndexPrivilege... values) {
this.privileges = _listAdd(this.privileges, value.jsonValue(),
Arrays.stream(values).map(IndexPrivilege::jsonValue).toArray(String[]::new));
return this;
}
/**
* Search queries that define the documents the user has access to. A document
* within the specified indices must match these queries for it to be accessible
* by the owners of the role.
* <p>
* API name: {@code query}
* <p>
* Adds all elements of <code>list</code> to <code>query</code>.
*/
public final Builder query(List<IndicesPrivilegesQuery> list) {
this.query = _listAddAll(this.query, list);
return this;
}
/**
* Search queries that define the documents the user has access to. A document
* within the specified indices must match these queries for it to be accessible
* by the owners of the role.
* <p>
* API name: {@code query}
* <p>
* Adds one or more values to <code>query</code>.
*/
public final Builder query(IndicesPrivilegesQuery value, IndicesPrivilegesQuery... values) {
this.query = _listAdd(this.query, value, values);
return this;
}
/**
* Search queries that define the documents the user has access to. A document
* within the specified indices must match these queries for it to be accessible
* by the owners of the role.
* <p>
* API name: {@code query}
* <p>
* Adds a value to <code>query</code> using a builder lambda.
*/
public final Builder query(Function<IndicesPrivilegesQuery.Builder, ObjectBuilder<IndicesPrivilegesQuery>> fn) {
return query(fn.apply(new IndicesPrivilegesQuery.Builder()).build());
}
/**
* Required - Set to <code>true</code> if using wildcard or regular expressions
* for patterns that cover restricted indices. Implicitly, restricted indices
* have limited privileges that can cause pattern tests to fail. If restricted
* indices are explicitly included in the <code>names</code> list, Elasticsearch
* checks privileges against these indices regardless of the value set for
* <code>allow_restricted_indices</code>.
* <p>
* API name: {@code allow_restricted_indices}
*/
public final Builder allowRestrictedIndices(boolean value) {
this.allowRestrictedIndices = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link RemoteUserIndicesPrivileges}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public RemoteUserIndicesPrivileges build() {
_checkSingleUse();
return new RemoteUserIndicesPrivileges(this);
}
}
/**
* @return New {@link Builder} initialized with field values of this instance
*/
public Builder rebuild() {
return new Builder(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link RemoteUserIndicesPrivileges}
*/
public static final JsonpDeserializer<RemoteUserIndicesPrivileges> _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, RemoteUserIndicesPrivileges::setupRemoteUserIndicesPrivilegesDeserializer);
protected static void setupRemoteUserIndicesPrivilegesDeserializer(
ObjectDeserializer<RemoteUserIndicesPrivileges.Builder> op) {
op.add(Builder::clusters, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"clusters");
op.add(Builder::fieldSecurity, JsonpDeserializer.arrayDeserializer(FieldSecurity._DESERIALIZER),
"field_security");
op.add(Builder::names, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "names");
op.add(Builder::privileges, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"privileges");
op.add(Builder::query, JsonpDeserializer.arrayDeserializer(IndicesPrivilegesQuery._DESERIALIZER), "query");
op.add(Builder::allowRestrictedIndices, JsonpDeserializer.booleanDeserializer(), "allow_restricted_indices");
}
}