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

co.elastic.clients.elasticsearch.cluster.PutComponentTemplateRequest 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.cluster;

import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.RequestBase;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch.indices.IndexState;
import co.elastic.clients.json.JsonData;
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.transport.Endpoint;
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.Long;
import java.lang.String;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: cluster.put_component_template.Request

/**
 * Creates or updates a component template
 * 
 * @see API
 *      specification
 */
@JsonpDeserializable
public class PutComponentTemplateRequest extends RequestBase implements JsonpSerializable {
	private final Map meta;

	@Nullable
	private final Boolean allowAutoCreate;

	@Nullable
	private final Boolean create;

	@Nullable
	private final Time masterTimeout;

	private final String name;

	private final IndexState template;

	@Nullable
	private final Long version;

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

	private PutComponentTemplateRequest(Builder builder) {

		this.meta = ApiTypeHelper.unmodifiable(builder.meta);
		this.allowAutoCreate = builder.allowAutoCreate;
		this.create = builder.create;
		this.masterTimeout = builder.masterTimeout;
		this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
		this.template = ApiTypeHelper.requireNonNull(builder.template, this, "template");
		this.version = builder.version;

	}

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

	/**
	 * Optional user metadata about the component template. May have any contents.
	 * This map is not automatically generated by Elasticsearch.
	 * 

* API name: {@code _meta} */ public final Map meta() { return this.meta; } /** * This setting overrides the value of the action.auto_create_index * cluster setting. If set to true in a template, then indices can * be automatically created using that template even if auto-creation of indices * is disabled via actions.auto_create_index. If set to * false then data streams matching the template must always be * explicitly created. *

* API name: {@code allow_auto_create} */ @Nullable public final Boolean allowAutoCreate() { return this.allowAutoCreate; } /** * Whether the index template should only be added if new or can also replace an * existing one *

* API name: {@code create} */ @Nullable public final Boolean create() { return this.create; } /** * Specify timeout for connection to master *

* API name: {@code master_timeout} */ @Nullable public final Time masterTimeout() { return this.masterTimeout; } /** * Required - The name of the template *

* API name: {@code name} */ public final String name() { return this.name; } /** * Required - The template to be applied which includes mappings, settings, or * aliases configuration. *

* API name: {@code template} */ public final IndexState template() { return this.template; } /** * Version number used to manage component templates externally. This number * isn't automatically generated or incremented by Elasticsearch. *

* API name: {@code version} */ @Nullable public final Long version() { return this.version; } /** * 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.meta)) { generator.writeKey("_meta"); generator.writeStartObject(); for (Map.Entry item0 : this.meta.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.allowAutoCreate != null) { generator.writeKey("allow_auto_create"); generator.write(this.allowAutoCreate); } generator.writeKey("template"); this.template.serialize(generator, mapper); if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link PutComponentTemplateRequest}. */ public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { @Nullable private Map meta; @Nullable private Boolean allowAutoCreate; @Nullable private Boolean create; @Nullable private Time masterTimeout; private String name; private IndexState template; @Nullable private Long version; /** * Optional user metadata about the component template. May have any contents. * This map is not automatically generated by Elasticsearch. *

* API name: {@code _meta} *

* Adds all entries of map to meta. */ public final Builder meta(Map map) { this.meta = _mapPutAll(this.meta, map); return this; } /** * Optional user metadata about the component template. May have any contents. * This map is not automatically generated by Elasticsearch. *

* API name: {@code _meta} *

* Adds an entry to meta. */ public final Builder meta(String key, JsonData value) { this.meta = _mapPut(this.meta, key, value); return this; } /** * This setting overrides the value of the action.auto_create_index * cluster setting. If set to true in a template, then indices can * be automatically created using that template even if auto-creation of indices * is disabled via actions.auto_create_index. If set to * false then data streams matching the template must always be * explicitly created. *

* API name: {@code allow_auto_create} */ public final Builder allowAutoCreate(@Nullable Boolean value) { this.allowAutoCreate = value; return this; } /** * Whether the index template should only be added if new or can also replace an * existing one *

* API name: {@code create} */ public final Builder create(@Nullable Boolean value) { this.create = value; return this; } /** * Specify timeout for connection to master *

* API name: {@code master_timeout} */ public final Builder masterTimeout(@Nullable Time value) { this.masterTimeout = value; return this; } /** * Specify timeout for connection to master *

* API name: {@code master_timeout} */ public final Builder masterTimeout(Function> fn) { return this.masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Required - The name of the template *

* API name: {@code name} */ public final Builder name(String value) { this.name = value; return this; } /** * Required - The template to be applied which includes mappings, settings, or * aliases configuration. *

* API name: {@code template} */ public final Builder template(IndexState value) { this.template = value; return this; } /** * Required - The template to be applied which includes mappings, settings, or * aliases configuration. *

* API name: {@code template} */ public final Builder template(Function> fn) { return this.template(fn.apply(new IndexState.Builder()).build()); } /** * Version number used to manage component templates externally. This number * isn't automatically generated or incremented by Elasticsearch. *

* API name: {@code version} */ public final Builder version(@Nullable Long value) { this.version = value; return this; } @Override protected Builder self() { return this; } /** * Builds a {@link PutComponentTemplateRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public PutComponentTemplateRequest build() { _checkSingleUse(); return new PutComponentTemplateRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link PutComponentTemplateRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, PutComponentTemplateRequest::setupPutComponentTemplateRequestDeserializer); protected static void setupPutComponentTemplateRequestDeserializer( ObjectDeserializer op) { op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); op.add(Builder::allowAutoCreate, JsonpDeserializer.booleanDeserializer(), "allow_auto_create"); op.add(Builder::template, IndexState._DESERIALIZER, "template"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code cluster.put_component_template}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/cluster.put_component_template", // Request method request -> { return "PUT"; }, // Request path request -> { final int _name = 1 << 0; int propsSet = 0; propsSet |= _name; if (propsSet == (_name)) { StringBuilder buf = new StringBuilder(); buf.append("/_component_template"); buf.append("/"); SimpleEndpoint.pathEncode(request.name, buf); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); if (request.masterTimeout != null) { params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.create != null) { params.put("create", String.valueOf(request.create)); } return params; }, SimpleEndpoint.emptyMap(), true, PutComponentTemplateResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy