co.elastic.clients.elasticsearch.security.InvalidateApiKeyResponse Maven / Gradle / Ivy
Show all versions of elasticsearch-java Show documentation
/*
* 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.elasticsearch._types.ErrorCause;
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.Integer;
import java.lang.String;
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.invalidate_api_key.Response
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class InvalidateApiKeyResponse implements JsonpSerializable {
private final int errorCount;
private final List errorDetails;
private final List invalidatedApiKeys;
private final List previouslyInvalidatedApiKeys;
// ---------------------------------------------------------------------------------------------
private InvalidateApiKeyResponse(Builder builder) {
this.errorCount = ApiTypeHelper.requireNonNull(builder.errorCount, this, "errorCount");
this.errorDetails = ApiTypeHelper.unmodifiable(builder.errorDetails);
this.invalidatedApiKeys = ApiTypeHelper.unmodifiableRequired(builder.invalidatedApiKeys, this,
"invalidatedApiKeys");
this.previouslyInvalidatedApiKeys = ApiTypeHelper.unmodifiableRequired(builder.previouslyInvalidatedApiKeys,
this, "previouslyInvalidatedApiKeys");
}
public static InvalidateApiKeyResponse of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* Required - API name: {@code error_count}
*/
public final int errorCount() {
return this.errorCount;
}
/**
* API name: {@code error_details}
*/
public final List errorDetails() {
return this.errorDetails;
}
/**
* Required - API name: {@code invalidated_api_keys}
*/
public final List invalidatedApiKeys() {
return this.invalidatedApiKeys;
}
/**
* Required - API name: {@code previously_invalidated_api_keys}
*/
public final List previouslyInvalidatedApiKeys() {
return this.previouslyInvalidatedApiKeys;
}
/**
* 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) {
generator.writeKey("error_count");
generator.write(this.errorCount);
if (ApiTypeHelper.isDefined(this.errorDetails)) {
generator.writeKey("error_details");
generator.writeStartArray();
for (ErrorCause item0 : this.errorDetails) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.invalidatedApiKeys)) {
generator.writeKey("invalidated_api_keys");
generator.writeStartArray();
for (String item0 : this.invalidatedApiKeys) {
generator.write(item0);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.previouslyInvalidatedApiKeys)) {
generator.writeKey("previously_invalidated_api_keys");
generator.writeStartArray();
for (String item0 : this.previouslyInvalidatedApiKeys) {
generator.write(item0);
}
generator.writeEnd();
}
}
@Override
public String toString() {
return JsonpUtils.toString(this);
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link InvalidateApiKeyResponse}.
*/
public static class Builder extends WithJsonObjectBuilderBase
implements
ObjectBuilder {
private Integer errorCount;
@Nullable
private List errorDetails;
private List invalidatedApiKeys;
private List previouslyInvalidatedApiKeys;
/**
* Required - API name: {@code error_count}
*/
public final Builder errorCount(int value) {
this.errorCount = value;
return this;
}
/**
* API name: {@code error_details}
*
* Adds all elements of list
to errorDetails
.
*/
public final Builder errorDetails(List list) {
this.errorDetails = _listAddAll(this.errorDetails, list);
return this;
}
/**
* API name: {@code error_details}
*
* Adds one or more values to errorDetails
.
*/
public final Builder errorDetails(ErrorCause value, ErrorCause... values) {
this.errorDetails = _listAdd(this.errorDetails, value, values);
return this;
}
/**
* API name: {@code error_details}
*
* Adds a value to errorDetails
using a builder lambda.
*/
public final Builder errorDetails(Function> fn) {
return errorDetails(fn.apply(new ErrorCause.Builder()).build());
}
/**
* Required - API name: {@code invalidated_api_keys}
*
* Adds all elements of list
to invalidatedApiKeys
.
*/
public final Builder invalidatedApiKeys(List list) {
this.invalidatedApiKeys = _listAddAll(this.invalidatedApiKeys, list);
return this;
}
/**
* Required - API name: {@code invalidated_api_keys}
*
* Adds one or more values to invalidatedApiKeys
.
*/
public final Builder invalidatedApiKeys(String value, String... values) {
this.invalidatedApiKeys = _listAdd(this.invalidatedApiKeys, value, values);
return this;
}
/**
* Required - API name: {@code previously_invalidated_api_keys}
*
* Adds all elements of list
to
* previouslyInvalidatedApiKeys
.
*/
public final Builder previouslyInvalidatedApiKeys(List list) {
this.previouslyInvalidatedApiKeys = _listAddAll(this.previouslyInvalidatedApiKeys, list);
return this;
}
/**
* Required - API name: {@code previously_invalidated_api_keys}
*
* Adds one or more values to previouslyInvalidatedApiKeys
.
*/
public final Builder previouslyInvalidatedApiKeys(String value, String... values) {
this.previouslyInvalidatedApiKeys = _listAdd(this.previouslyInvalidatedApiKeys, value, values);
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link InvalidateApiKeyResponse}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public InvalidateApiKeyResponse build() {
_checkSingleUse();
return new InvalidateApiKeyResponse(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Json deserializer for {@link InvalidateApiKeyResponse}
*/
public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, InvalidateApiKeyResponse::setupInvalidateApiKeyResponseDeserializer);
protected static void setupInvalidateApiKeyResponseDeserializer(
ObjectDeserializer op) {
op.add(Builder::errorCount, JsonpDeserializer.integerDeserializer(), "error_count");
op.add(Builder::errorDetails, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "error_details");
op.add(Builder::invalidatedApiKeys, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"invalidated_api_keys");
op.add(Builder::previouslyInvalidatedApiKeys,
JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"previously_invalidated_api_keys");
}
}