co.elastic.clients.elasticsearch.security.GetUserPrivilegesResponse Maven / Gradle / Ivy
/*
* 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.
*/
//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------
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.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.String;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
// typedef: security.get_user_privileges.Response
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class GetUserPrivilegesResponse implements JsonpSerializable {
private final List applications;
private final List cluster;
private final List global;
private final List indices;
private final List runAs;
// ---------------------------------------------------------------------------------------------
private GetUserPrivilegesResponse(Builder builder) {
this.applications = ApiTypeHelper.unmodifiableRequired(builder.applications, this, "applications");
this.cluster = ApiTypeHelper.unmodifiableRequired(builder.cluster, this, "cluster");
this.global = ApiTypeHelper.unmodifiableRequired(builder.global, this, "global");
this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices");
this.runAs = ApiTypeHelper.unmodifiableRequired(builder.runAs, this, "runAs");
}
public static GetUserPrivilegesResponse of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* Required - API name: {@code applications}
*/
public final List applications() {
return this.applications;
}
/**
* Required - API name: {@code cluster}
*/
public final List cluster() {
return this.cluster;
}
/**
* Required - API name: {@code global}
*/
public final List global() {
return this.global;
}
/**
* Required - API name: {@code indices}
*/
public final List indices() {
return this.indices;
}
/**
* Required - API name: {@code run_as}
*/
public final List runAs() {
return this.runAs;
}
/**
* 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.applications)) {
generator.writeKey("applications");
generator.writeStartArray();
for (ApplicationPrivileges item0 : this.applications) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.cluster)) {
generator.writeKey("cluster");
generator.writeStartArray();
for (String item0 : this.cluster) {
generator.write(item0);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.global)) {
generator.writeKey("global");
generator.writeStartArray();
for (GlobalPrivilege item0 : this.global) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.indices)) {
generator.writeKey("indices");
generator.writeStartArray();
for (IndicesPrivileges item0 : this.indices) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.runAs)) {
generator.writeKey("run_as");
generator.writeStartArray();
for (String item0 : this.runAs) {
generator.write(item0);
}
generator.writeEnd();
}
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link GetUserPrivilegesResponse}.
*/
public static class Builder extends WithJsonObjectBuilderBase
implements
ObjectBuilder {
private List applications;
private List cluster;
private List global;
private List indices;
private List runAs;
/**
* Required - API name: {@code applications}
*
* Adds all elements of list
to applications
.
*/
public final Builder applications(List list) {
this.applications = _listAddAll(this.applications, list);
return this;
}
/**
* Required - API name: {@code applications}
*
* Adds one or more values to applications
.
*/
public final Builder applications(ApplicationPrivileges value, ApplicationPrivileges... values) {
this.applications = _listAdd(this.applications, value, values);
return this;
}
/**
* Required - API name: {@code applications}
*
* Adds a value to applications
using a builder lambda.
*/
public final Builder applications(
Function> fn) {
return applications(fn.apply(new ApplicationPrivileges.Builder()).build());
}
/**
* Required - API name: {@code cluster}
*
* Adds all elements of list
to cluster
.
*/
public final Builder cluster(List list) {
this.cluster = _listAddAll(this.cluster, list);
return this;
}
/**
* Required - API name: {@code cluster}
*
* Adds one or more values to cluster
.
*/
public final Builder cluster(String value, String... values) {
this.cluster = _listAdd(this.cluster, value, values);
return this;
}
/**
* Required - API name: {@code global}
*
* Adds all elements of list
to global
.
*/
public final Builder global(List list) {
this.global = _listAddAll(this.global, list);
return this;
}
/**
* Required - API name: {@code global}
*
* Adds one or more values to global
.
*/
public final Builder global(GlobalPrivilege value, GlobalPrivilege... values) {
this.global = _listAdd(this.global, value, values);
return this;
}
/**
* Required - API name: {@code global}
*
* Adds a value to global
using a builder lambda.
*/
public final Builder global(Function> fn) {
return global(fn.apply(new GlobalPrivilege.Builder()).build());
}
/**
* Required - API name: {@code indices}
*
* Adds all elements of list
to indices
.
*/
public final Builder indices(List list) {
this.indices = _listAddAll(this.indices, list);
return this;
}
/**
* Required - API name: {@code indices}
*
* Adds one or more values to indices
.
*/
public final Builder indices(IndicesPrivileges value, IndicesPrivileges... values) {
this.indices = _listAdd(this.indices, value, values);
return this;
}
/**
* Required - API name: {@code indices}
*
* Adds a value to indices
using a builder lambda.
*/
public final Builder indices(Function> fn) {
return indices(fn.apply(new IndicesPrivileges.Builder()).build());
}
/**
* Required - API name: {@code run_as}
*
* Adds all elements of list
to runAs
.
*/
public final Builder runAs(List list) {
this.runAs = _listAddAll(this.runAs, list);
return this;
}
/**
* Required - API name: {@code run_as}
*
* Adds one or more values to runAs
.
*/
public final Builder runAs(String value, String... values) {
this.runAs = _listAdd(this.runAs, value, values);
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link GetUserPrivilegesResponse}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public GetUserPrivilegesResponse build() {
_checkSingleUse();
return new GetUserPrivilegesResponse(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link GetUserPrivilegesResponse}
*/
public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, GetUserPrivilegesResponse::setupGetUserPrivilegesResponseDeserializer);
protected static void setupGetUserPrivilegesResponseDeserializer(
ObjectDeserializer op) {
op.add(Builder::applications, JsonpDeserializer.arrayDeserializer(ApplicationPrivileges._DESERIALIZER),
"applications");
op.add(Builder::cluster, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"cluster");
op.add(Builder::global, JsonpDeserializer.arrayDeserializer(GlobalPrivilege._DESERIALIZER), "global");
op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(IndicesPrivileges._DESERIALIZER), "indices");
op.add(Builder::runAs, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "run_as");
}
}