All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.elastic.clients.elasticsearch.license.PostStartBasicResponse Maven / Gradle / Ivy

There is a newer version: 8.17.0
Show newest version
/*
 * 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.license;

import co.elastic.clients.elasticsearch._types.AcknowledgedResponse;
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.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: license.post_start_basic.Response

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class PostStartBasicResponse implements AcknowledgedResponse, JsonpSerializable {
	private final boolean acknowledged;

	private final boolean basicWasStarted;

	@Nullable
	private final String errorMessage;

	@Nullable
	private final LicenseType type;

	private final Map> acknowledge;

	// ---------------------------------------------------------------------------------------------

	private PostStartBasicResponse(Builder builder) {

		this.acknowledged = ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged");
		this.basicWasStarted = ApiTypeHelper.requireNonNull(builder.basicWasStarted, this, "basicWasStarted");
		this.errorMessage = builder.errorMessage;
		this.type = builder.type;
		this.acknowledge = ApiTypeHelper.unmodifiable(builder.acknowledge);

	}

	public static PostStartBasicResponse of(Function> fn) {
		return fn.apply(new Builder()).build();
	}

	/**
	 * Required - API name: {@code acknowledged}
	 */
	public final boolean acknowledged() {
		return this.acknowledged;
	}

	/**
	 * Required - API name: {@code basic_was_started}
	 */
	public final boolean basicWasStarted() {
		return this.basicWasStarted;
	}

	/**
	 * API name: {@code error_message}
	 */
	@Nullable
	public final String errorMessage() {
		return this.errorMessage;
	}

	/**
	 * API name: {@code type}
	 */
	@Nullable
	public final LicenseType type() {
		return this.type;
	}

	/**
	 * API name: {@code acknowledge}
	 */
	public final Map> acknowledge() {
		return this.acknowledge;
	}

	/**
	 * 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("acknowledged");
		generator.write(this.acknowledged);

		generator.writeKey("basic_was_started");
		generator.write(this.basicWasStarted);

		if (this.errorMessage != null) {
			generator.writeKey("error_message");
			generator.write(this.errorMessage);

		}
		if (this.type != null) {
			generator.writeKey("type");
			this.type.serialize(generator, mapper);
		}
		if (ApiTypeHelper.isDefined(this.acknowledge)) {
			generator.writeKey("acknowledge");
			generator.writeStartObject();
			for (Map.Entry> item0 : this.acknowledge.entrySet()) {
				generator.writeKey(item0.getKey());
				generator.writeStartArray();
				if (item0.getValue() != null) {
					for (String item1 : item0.getValue()) {
						generator.write(item1);

					}
				}
				generator.writeEnd();

			}
			generator.writeEnd();

		}

	}

	// ---------------------------------------------------------------------------------------------

	/**
	 * Builder for {@link PostStartBasicResponse}.
	 */

	public static class Builder extends WithJsonObjectBuilderBase
			implements
				ObjectBuilder {
		private Boolean acknowledged;

		private Boolean basicWasStarted;

		@Nullable
		private String errorMessage;

		@Nullable
		private LicenseType type;

		@Nullable
		private Map> acknowledge;

		/**
		 * Required - API name: {@code acknowledged}
		 */
		public final Builder acknowledged(boolean value) {
			this.acknowledged = value;
			return this;
		}

		/**
		 * Required - API name: {@code basic_was_started}
		 */
		public final Builder basicWasStarted(boolean value) {
			this.basicWasStarted = value;
			return this;
		}

		/**
		 * API name: {@code error_message}
		 */
		public final Builder errorMessage(@Nullable String value) {
			this.errorMessage = value;
			return this;
		}

		/**
		 * API name: {@code type}
		 */
		public final Builder type(@Nullable LicenseType value) {
			this.type = value;
			return this;
		}

		/**
		 * API name: {@code acknowledge}
		 * 

* Adds all entries of map to acknowledge. */ public final Builder acknowledge(Map> map) { this.acknowledge = _mapPutAll(this.acknowledge, map); return this; } /** * API name: {@code acknowledge} *

* Adds an entry to acknowledge. */ public final Builder acknowledge(String key, List value) { this.acknowledge = _mapPut(this.acknowledge, key, value); return this; } @Override protected Builder self() { return this; } /** * Builds a {@link PostStartBasicResponse}. * * @throws NullPointerException * if some of the required fields are null. */ public PostStartBasicResponse build() { _checkSingleUse(); return new PostStartBasicResponse(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link PostStartBasicResponse} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, PostStartBasicResponse::setupPostStartBasicResponseDeserializer); protected static void setupPostStartBasicResponseDeserializer( ObjectDeserializer op) { op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); op.add(Builder::basicWasStarted, JsonpDeserializer.booleanDeserializer(), "basic_was_started"); op.add(Builder::errorMessage, JsonpDeserializer.stringDeserializer(), "error_message"); op.add(Builder::type, LicenseType._DESERIALIZER, "type"); op.add(Builder::acknowledge, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer())), "acknowledge"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy