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

co.elastic.clients.elasticsearch.core.OpenPointInTimeRequest 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.core;

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.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
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 co.elastic.clients.util.ObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;

// typedef: _global.open_point_in_time.Request

/**
 * A search request by default executes against the most recent visible data of
 * the target indices, which is called point in time. Elasticsearch pit (point
 * in time) is a lightweight view into the state of the data as it existed when
 * initiated. In some cases, it’s preferred to perform multiple search requests
 * using the same point in time. For example, if refreshes happen between
 * search_after requests, then the results of those requests might
 * not be consistent as changes happening between searches are only visible to
 * the more recent point in time.
 * 
 * @see API
 *      specification
 */

public class OpenPointInTimeRequest extends RequestBase {
	@Nullable
	private final Boolean ignoreUnavailable;

	private final List index;

	private final Time keepAlive;

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

	private OpenPointInTimeRequest(Builder builder) {

		this.ignoreUnavailable = builder.ignoreUnavailable;
		this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index");
		this.keepAlive = ApiTypeHelper.requireNonNull(builder.keepAlive, this, "keepAlive");

	}

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

	/**
	 * Whether specified concrete indices should be ignored when unavailable
	 * (missing or closed)
	 * 

* API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * Required - A comma-separated list of index names to open point in time; use * _all or empty string to perform the operation on all indices *

* API name: {@code index} */ public final List index() { return this.index; } /** * Required - Specific the time to live for the point in time *

* API name: {@code keep_alive} */ public final Time keepAlive() { return this.keepAlive; } // --------------------------------------------------------------------------------------------- /** * Builder for {@link OpenPointInTimeRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Boolean ignoreUnavailable; private List index; private Time keepAlive; /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) *

* API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * Required - A comma-separated list of index names to open point in time; use * _all or empty string to perform the operation on all indices *

* API name: {@code index} *

* Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * Required - A comma-separated list of index names to open point in time; use * _all or empty string to perform the operation on all indices *

* API name: {@code index} *

* Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Required - Specific the time to live for the point in time *

* API name: {@code keep_alive} */ public final Builder keepAlive(Time value) { this.keepAlive = value; return this; } /** * Required - Specific the time to live for the point in time *

* API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link OpenPointInTimeRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public OpenPointInTimeRequest build() { _checkSingleUse(); return new OpenPointInTimeRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code open_point_in_time}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/open_point_in_time", // Request method request -> { return "POST"; }, // 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.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_pit"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } params.put("keep_alive", request.keepAlive._toJsonString()); return params; }, SimpleEndpoint.emptyMap(), false, OpenPointInTimeResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy