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

co.elastic.clients.elasticsearch.ml.PutDatafeedResponse 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.ml;

import co.elastic.clients.elasticsearch._types.IndicesOptions;
import co.elastic.clients.elasticsearch._types.ScriptField;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
import co.elastic.clients.elasticsearch._types.mapping.RuntimeField;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
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.Integer;
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: ml.put_datafeed.Response

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class PutDatafeedResponse implements JsonpSerializable {
	private final Map aggregations;

	private final ChunkingConfig chunkingConfig;

	@Nullable
	private final DelayedDataCheckConfig delayedDataCheckConfig;

	private final String datafeedId;

	private final Time frequency;

	private final List indices;

	private final String jobId;

	@Nullable
	private final IndicesOptions indicesOptions;

	private final int maxEmptySearches;

	private final Query query;

	private final Time queryDelay;

	private final Map> runtimeMappings;

	private final Map scriptFields;

	private final int scrollSize;

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

	private PutDatafeedResponse(Builder builder) {

		this.aggregations = ApiTypeHelper.unmodifiableRequired(builder.aggregations, this, "aggregations");
		this.chunkingConfig = ApiTypeHelper.requireNonNull(builder.chunkingConfig, this, "chunkingConfig");
		this.delayedDataCheckConfig = builder.delayedDataCheckConfig;
		this.datafeedId = ApiTypeHelper.requireNonNull(builder.datafeedId, this, "datafeedId");
		this.frequency = ApiTypeHelper.requireNonNull(builder.frequency, this, "frequency");
		this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices");
		this.jobId = ApiTypeHelper.requireNonNull(builder.jobId, this, "jobId");
		this.indicesOptions = builder.indicesOptions;
		this.maxEmptySearches = ApiTypeHelper.requireNonNull(builder.maxEmptySearches, this, "maxEmptySearches");
		this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query");
		this.queryDelay = ApiTypeHelper.requireNonNull(builder.queryDelay, this, "queryDelay");
		this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings);
		this.scriptFields = ApiTypeHelper.unmodifiable(builder.scriptFields);
		this.scrollSize = ApiTypeHelper.requireNonNull(builder.scrollSize, this, "scrollSize");

	}

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

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

	/**
	 * Required - API name: {@code chunking_config}
	 */
	public final ChunkingConfig chunkingConfig() {
		return this.chunkingConfig;
	}

	/**
	 * API name: {@code delayed_data_check_config}
	 */
	@Nullable
	public final DelayedDataCheckConfig delayedDataCheckConfig() {
		return this.delayedDataCheckConfig;
	}

	/**
	 * Required - API name: {@code datafeed_id}
	 */
	public final String datafeedId() {
		return this.datafeedId;
	}

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

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

	/**
	 * Required - API name: {@code job_id}
	 */
	public final String jobId() {
		return this.jobId;
	}

	/**
	 * API name: {@code indices_options}
	 */
	@Nullable
	public final IndicesOptions indicesOptions() {
		return this.indicesOptions;
	}

	/**
	 * Required - API name: {@code max_empty_searches}
	 */
	public final int maxEmptySearches() {
		return this.maxEmptySearches;
	}

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

	/**
	 * Required - API name: {@code query_delay}
	 */
	public final Time queryDelay() {
		return this.queryDelay;
	}

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

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

	/**
	 * Required - API name: {@code scroll_size}
	 */
	public final int scrollSize() {
		return this.scrollSize;
	}

	/**
	 * 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.aggregations)) {
			generator.writeKey("aggregations");
			generator.writeStartObject();
			for (Map.Entry item0 : this.aggregations.entrySet()) {
				generator.writeKey(item0.getKey());
				item0.getValue().serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		generator.writeKey("chunking_config");
		this.chunkingConfig.serialize(generator, mapper);

		if (this.delayedDataCheckConfig != null) {
			generator.writeKey("delayed_data_check_config");
			this.delayedDataCheckConfig.serialize(generator, mapper);

		}
		generator.writeKey("datafeed_id");
		generator.write(this.datafeedId);

		generator.writeKey("frequency");
		this.frequency.serialize(generator, mapper);

		if (ApiTypeHelper.isDefined(this.indices)) {
			generator.writeKey("indices");
			generator.writeStartArray();
			for (String item0 : this.indices) {
				generator.write(item0);

			}
			generator.writeEnd();

		}
		generator.writeKey("job_id");
		generator.write(this.jobId);

		if (this.indicesOptions != null) {
			generator.writeKey("indices_options");
			this.indicesOptions.serialize(generator, mapper);

		}
		generator.writeKey("max_empty_searches");
		generator.write(this.maxEmptySearches);

		generator.writeKey("query");
		this.query.serialize(generator, mapper);

		generator.writeKey("query_delay");
		this.queryDelay.serialize(generator, mapper);

		if (ApiTypeHelper.isDefined(this.runtimeMappings)) {
			generator.writeKey("runtime_mappings");
			generator.writeStartObject();
			for (Map.Entry> item0 : this.runtimeMappings.entrySet()) {
				generator.writeKey(item0.getKey());
				generator.writeStartArray();
				if (item0.getValue() != null) {
					for (RuntimeField item1 : item0.getValue()) {
						item1.serialize(generator, mapper);

					}
				}
				generator.writeEnd();

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.scriptFields)) {
			generator.writeKey("script_fields");
			generator.writeStartObject();
			for (Map.Entry item0 : this.scriptFields.entrySet()) {
				generator.writeKey(item0.getKey());
				item0.getValue().serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		generator.writeKey("scroll_size");
		generator.write(this.scrollSize);

	}

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

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

	public static class Builder extends WithJsonObjectBuilderBase
			implements
				ObjectBuilder {
		private Map aggregations;

		private ChunkingConfig chunkingConfig;

		@Nullable
		private DelayedDataCheckConfig delayedDataCheckConfig;

		private String datafeedId;

		private Time frequency;

		private List indices;

		private String jobId;

		@Nullable
		private IndicesOptions indicesOptions;

		private Integer maxEmptySearches;

		private Query query;

		private Time queryDelay;

		@Nullable
		private Map> runtimeMappings;

		@Nullable
		private Map scriptFields;

		private Integer scrollSize;

		/**
		 * Required - API name: {@code aggregations}
		 * 

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

* Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * Required - API name: {@code aggregations} *

* Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Required - API name: {@code chunking_config} */ public final Builder chunkingConfig(ChunkingConfig value) { this.chunkingConfig = value; return this; } /** * Required - API name: {@code chunking_config} */ public final Builder chunkingConfig(Function> fn) { return this.chunkingConfig(fn.apply(new ChunkingConfig.Builder()).build()); } /** * API name: {@code delayed_data_check_config} */ public final Builder delayedDataCheckConfig(@Nullable DelayedDataCheckConfig value) { this.delayedDataCheckConfig = value; return this; } /** * API name: {@code delayed_data_check_config} */ public final Builder delayedDataCheckConfig( Function> fn) { return this.delayedDataCheckConfig(fn.apply(new DelayedDataCheckConfig.Builder()).build()); } /** * Required - API name: {@code datafeed_id} */ public final Builder datafeedId(String value) { this.datafeedId = value; return this; } /** * Required - API name: {@code frequency} */ public final Builder frequency(Time value) { this.frequency = value; return this; } /** * Required - API name: {@code frequency} */ public final Builder frequency(Function> fn) { return this.frequency(fn.apply(new Time.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(String value, String... values) { this.indices = _listAdd(this.indices, value, values); return this; } /** * Required - API name: {@code job_id} */ public final Builder jobId(String value) { this.jobId = value; return this; } /** * API name: {@code indices_options} */ public final Builder indicesOptions(@Nullable IndicesOptions value) { this.indicesOptions = value; return this; } /** * API name: {@code indices_options} */ public final Builder indicesOptions(Function> fn) { return this.indicesOptions(fn.apply(new IndicesOptions.Builder()).build()); } /** * Required - API name: {@code max_empty_searches} */ public final Builder maxEmptySearches(int value) { this.maxEmptySearches = value; return this; } /** * Required - API name: {@code query} */ public final Builder query(Query value) { this.query = value; return this; } /** * Required - API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Required - API name: {@code query_delay} */ public final Builder queryDelay(Time value) { this.queryDelay = value; return this; } /** * Required - API name: {@code query_delay} */ public final Builder queryDelay(Function> fn) { return this.queryDelay(fn.apply(new Time.Builder()).build()); } /** * API name: {@code runtime_mappings} *

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

* Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * API name: {@code script_fields} *

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

* Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * API name: {@code script_fields} *

* Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * Required - API name: {@code scroll_size} */ public final Builder scrollSize(int value) { this.scrollSize = value; return this; } @Override protected Builder self() { return this; } /** * Builds a {@link PutDatafeedResponse}. * * @throws NullPointerException * if some of the required fields are null. */ public PutDatafeedResponse build() { _checkSingleUse(); return new PutDatafeedResponse(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link PutDatafeedResponse} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, PutDatafeedResponse::setupPutDatafeedResponseDeserializer); protected static void setupPutDatafeedResponseDeserializer(ObjectDeserializer op) { op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations"); op.add(Builder::chunkingConfig, ChunkingConfig._DESERIALIZER, "chunking_config"); op.add(Builder::delayedDataCheckConfig, DelayedDataCheckConfig._DESERIALIZER, "delayed_data_check_config"); op.add(Builder::datafeedId, JsonpDeserializer.stringDeserializer(), "datafeed_id"); op.add(Builder::frequency, Time._DESERIALIZER, "frequency"); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::jobId, JsonpDeserializer.stringDeserializer(), "job_id"); op.add(Builder::indicesOptions, IndicesOptions._DESERIALIZER, "indices_options"); op.add(Builder::maxEmptySearches, JsonpDeserializer.integerDeserializer(), "max_empty_searches"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::queryDelay, Time._DESERIALIZER, "query_delay"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::scrollSize, JsonpDeserializer.integerDeserializer(), "scroll_size"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy