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

co.elastic.clients.elasticsearch.ccr.FollowRequest Maven / Gradle / Ivy

The 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.
 */

package co.elastic.clients.elasticsearch.ccr;

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._types.WaitForActiveShards;
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.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;

//----------------------------------------------------------------
//       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: ccr.follow.Request

/**
 * Creates a new follower index configured to follow the referenced leader
 * index.
 * 
 * @see API
 *      specification
 */
@JsonpDeserializable
public class FollowRequest extends RequestBase implements JsonpSerializable {
	private final String index;

	@Nullable
	private final String leaderIndex;

	@Nullable
	private final Long maxOutstandingReadRequests;

	@Nullable
	private final Long maxOutstandingWriteRequests;

	@Nullable
	private final Long maxReadRequestOperationCount;

	@Nullable
	private final String maxReadRequestSize;

	@Nullable
	private final Time maxRetryDelay;

	@Nullable
	private final Long maxWriteBufferCount;

	@Nullable
	private final String maxWriteBufferSize;

	@Nullable
	private final Long maxWriteRequestOperationCount;

	@Nullable
	private final String maxWriteRequestSize;

	@Nullable
	private final Time readPollTimeout;

	@Nullable
	private final String remoteCluster;

	@Nullable
	private final WaitForActiveShards waitForActiveShards;

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

	private FollowRequest(Builder builder) {

		this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
		this.leaderIndex = builder.leaderIndex;
		this.maxOutstandingReadRequests = builder.maxOutstandingReadRequests;
		this.maxOutstandingWriteRequests = builder.maxOutstandingWriteRequests;
		this.maxReadRequestOperationCount = builder.maxReadRequestOperationCount;
		this.maxReadRequestSize = builder.maxReadRequestSize;
		this.maxRetryDelay = builder.maxRetryDelay;
		this.maxWriteBufferCount = builder.maxWriteBufferCount;
		this.maxWriteBufferSize = builder.maxWriteBufferSize;
		this.maxWriteRequestOperationCount = builder.maxWriteRequestOperationCount;
		this.maxWriteRequestSize = builder.maxWriteRequestSize;
		this.readPollTimeout = builder.readPollTimeout;
		this.remoteCluster = builder.remoteCluster;
		this.waitForActiveShards = builder.waitForActiveShards;

	}

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

	/**
	 * Required - The name of the follower index
	 * 

* API name: {@code index} */ public final String index() { return this.index; } /** * API name: {@code leader_index} */ @Nullable public final String leaderIndex() { return this.leaderIndex; } /** * API name: {@code max_outstanding_read_requests} */ @Nullable public final Long maxOutstandingReadRequests() { return this.maxOutstandingReadRequests; } /** * API name: {@code max_outstanding_write_requests} */ @Nullable public final Long maxOutstandingWriteRequests() { return this.maxOutstandingWriteRequests; } /** * API name: {@code max_read_request_operation_count} */ @Nullable public final Long maxReadRequestOperationCount() { return this.maxReadRequestOperationCount; } /** * API name: {@code max_read_request_size} */ @Nullable public final String maxReadRequestSize() { return this.maxReadRequestSize; } /** * API name: {@code max_retry_delay} */ @Nullable public final Time maxRetryDelay() { return this.maxRetryDelay; } /** * API name: {@code max_write_buffer_count} */ @Nullable public final Long maxWriteBufferCount() { return this.maxWriteBufferCount; } /** * API name: {@code max_write_buffer_size} */ @Nullable public final String maxWriteBufferSize() { return this.maxWriteBufferSize; } /** * API name: {@code max_write_request_operation_count} */ @Nullable public final Long maxWriteRequestOperationCount() { return this.maxWriteRequestOperationCount; } /** * API name: {@code max_write_request_size} */ @Nullable public final String maxWriteRequestSize() { return this.maxWriteRequestSize; } /** * API name: {@code read_poll_timeout} */ @Nullable public final Time readPollTimeout() { return this.readPollTimeout; } /** * API name: {@code remote_cluster} */ @Nullable public final String remoteCluster() { return this.remoteCluster; } /** * Sets the number of shard copies that must be active before returning. * Defaults to 0. Set to all for all shard copies, otherwise set to * any non-negative value less than or equal to the total number of copies for * the shard (number of replicas + 1) *

* API name: {@code wait_for_active_shards} */ @Nullable public final WaitForActiveShards waitForActiveShards() { return this.waitForActiveShards; } /** * 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 (this.leaderIndex != null) { generator.writeKey("leader_index"); generator.write(this.leaderIndex); } if (this.maxOutstandingReadRequests != null) { generator.writeKey("max_outstanding_read_requests"); generator.write(this.maxOutstandingReadRequests); } if (this.maxOutstandingWriteRequests != null) { generator.writeKey("max_outstanding_write_requests"); generator.write(this.maxOutstandingWriteRequests); } if (this.maxReadRequestOperationCount != null) { generator.writeKey("max_read_request_operation_count"); generator.write(this.maxReadRequestOperationCount); } if (this.maxReadRequestSize != null) { generator.writeKey("max_read_request_size"); generator.write(this.maxReadRequestSize); } if (this.maxRetryDelay != null) { generator.writeKey("max_retry_delay"); this.maxRetryDelay.serialize(generator, mapper); } if (this.maxWriteBufferCount != null) { generator.writeKey("max_write_buffer_count"); generator.write(this.maxWriteBufferCount); } if (this.maxWriteBufferSize != null) { generator.writeKey("max_write_buffer_size"); generator.write(this.maxWriteBufferSize); } if (this.maxWriteRequestOperationCount != null) { generator.writeKey("max_write_request_operation_count"); generator.write(this.maxWriteRequestOperationCount); } if (this.maxWriteRequestSize != null) { generator.writeKey("max_write_request_size"); generator.write(this.maxWriteRequestSize); } if (this.readPollTimeout != null) { generator.writeKey("read_poll_timeout"); this.readPollTimeout.serialize(generator, mapper); } if (this.remoteCluster != null) { generator.writeKey("remote_cluster"); generator.write(this.remoteCluster); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link FollowRequest}. */ public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { private String index; @Nullable private String leaderIndex; @Nullable private Long maxOutstandingReadRequests; @Nullable private Long maxOutstandingWriteRequests; @Nullable private Long maxReadRequestOperationCount; @Nullable private String maxReadRequestSize; @Nullable private Time maxRetryDelay; @Nullable private Long maxWriteBufferCount; @Nullable private String maxWriteBufferSize; @Nullable private Long maxWriteRequestOperationCount; @Nullable private String maxWriteRequestSize; @Nullable private Time readPollTimeout; @Nullable private String remoteCluster; @Nullable private WaitForActiveShards waitForActiveShards; /** * Required - The name of the follower index *

* API name: {@code index} */ public final Builder index(String value) { this.index = value; return this; } /** * API name: {@code leader_index} */ public final Builder leaderIndex(@Nullable String value) { this.leaderIndex = value; return this; } /** * API name: {@code max_outstanding_read_requests} */ public final Builder maxOutstandingReadRequests(@Nullable Long value) { this.maxOutstandingReadRequests = value; return this; } /** * API name: {@code max_outstanding_write_requests} */ public final Builder maxOutstandingWriteRequests(@Nullable Long value) { this.maxOutstandingWriteRequests = value; return this; } /** * API name: {@code max_read_request_operation_count} */ public final Builder maxReadRequestOperationCount(@Nullable Long value) { this.maxReadRequestOperationCount = value; return this; } /** * API name: {@code max_read_request_size} */ public final Builder maxReadRequestSize(@Nullable String value) { this.maxReadRequestSize = value; return this; } /** * API name: {@code max_retry_delay} */ public final Builder maxRetryDelay(@Nullable Time value) { this.maxRetryDelay = value; return this; } /** * API name: {@code max_retry_delay} */ public final Builder maxRetryDelay(Function> fn) { return this.maxRetryDelay(fn.apply(new Time.Builder()).build()); } /** * API name: {@code max_write_buffer_count} */ public final Builder maxWriteBufferCount(@Nullable Long value) { this.maxWriteBufferCount = value; return this; } /** * API name: {@code max_write_buffer_size} */ public final Builder maxWriteBufferSize(@Nullable String value) { this.maxWriteBufferSize = value; return this; } /** * API name: {@code max_write_request_operation_count} */ public final Builder maxWriteRequestOperationCount(@Nullable Long value) { this.maxWriteRequestOperationCount = value; return this; } /** * API name: {@code max_write_request_size} */ public final Builder maxWriteRequestSize(@Nullable String value) { this.maxWriteRequestSize = value; return this; } /** * API name: {@code read_poll_timeout} */ public final Builder readPollTimeout(@Nullable Time value) { this.readPollTimeout = value; return this; } /** * API name: {@code read_poll_timeout} */ public final Builder readPollTimeout(Function> fn) { return this.readPollTimeout(fn.apply(new Time.Builder()).build()); } /** * API name: {@code remote_cluster} */ public final Builder remoteCluster(@Nullable String value) { this.remoteCluster = value; return this; } /** * Sets the number of shard copies that must be active before returning. * Defaults to 0. Set to all for all shard copies, otherwise set to * any non-negative value less than or equal to the total number of copies for * the shard (number of replicas + 1) *

* API name: {@code wait_for_active_shards} */ public final Builder waitForActiveShards(@Nullable WaitForActiveShards value) { this.waitForActiveShards = value; return this; } /** * Sets the number of shard copies that must be active before returning. * Defaults to 0. Set to all for all shard copies, otherwise set to * any non-negative value less than or equal to the total number of copies for * the shard (number of replicas + 1) *

* API name: {@code wait_for_active_shards} */ public final Builder waitForActiveShards( Function> fn) { return this.waitForActiveShards(fn.apply(new WaitForActiveShards.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link FollowRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public FollowRequest build() { _checkSingleUse(); return new FollowRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link FollowRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, FollowRequest::setupFollowRequestDeserializer); protected static void setupFollowRequestDeserializer(ObjectDeserializer op) { op.add(Builder::leaderIndex, JsonpDeserializer.stringDeserializer(), "leader_index"); op.add(Builder::maxOutstandingReadRequests, JsonpDeserializer.longDeserializer(), "max_outstanding_read_requests"); op.add(Builder::maxOutstandingWriteRequests, JsonpDeserializer.longDeserializer(), "max_outstanding_write_requests"); op.add(Builder::maxReadRequestOperationCount, JsonpDeserializer.longDeserializer(), "max_read_request_operation_count"); op.add(Builder::maxReadRequestSize, JsonpDeserializer.stringDeserializer(), "max_read_request_size"); op.add(Builder::maxRetryDelay, Time._DESERIALIZER, "max_retry_delay"); op.add(Builder::maxWriteBufferCount, JsonpDeserializer.longDeserializer(), "max_write_buffer_count"); op.add(Builder::maxWriteBufferSize, JsonpDeserializer.stringDeserializer(), "max_write_buffer_size"); op.add(Builder::maxWriteRequestOperationCount, JsonpDeserializer.longDeserializer(), "max_write_request_operation_count"); op.add(Builder::maxWriteRequestSize, JsonpDeserializer.stringDeserializer(), "max_write_request_size"); op.add(Builder::readPollTimeout, Time._DESERIALIZER, "read_poll_timeout"); op.add(Builder::remoteCluster, JsonpDeserializer.stringDeserializer(), "remote_cluster"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code ccr.follow}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/ccr.follow", // Request method request -> { return "PUT"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; propsSet |= _index; if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index, buf); buf.append("/_ccr"); buf.append("/follow"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Path parameters request -> { Map params = new HashMap<>(); final int _index = 1 << 0; int propsSet = 0; propsSet |= _index; if (propsSet == (_index)) { params.put("index", request.index); } return params; }, // Request parameters request -> { Map params = new HashMap<>(); if (request.waitForActiveShards != null) { params.put("wait_for_active_shards", request.waitForActiveShards._toJsonString()); } return params; }, SimpleEndpoint.emptyMap(), true, FollowResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy