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

co.elastic.clients.elasticsearch.sql.GetAsyncResponse 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.sql;

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.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.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: sql.get_async.Response

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class GetAsyncResponse implements JsonpSerializable {
	private final String id;

	private final boolean isRunning;

	private final boolean isPartial;

	private final List columns;

	@Nullable
	private final String cursor;

	private final List> rows;

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

	private GetAsyncResponse(Builder builder) {

		this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id");
		this.isRunning = ApiTypeHelper.requireNonNull(builder.isRunning, this, "isRunning");
		this.isPartial = ApiTypeHelper.requireNonNull(builder.isPartial, this, "isPartial");
		this.columns = ApiTypeHelper.unmodifiable(builder.columns);
		this.cursor = builder.cursor;
		this.rows = ApiTypeHelper.unmodifiableRequired(builder.rows, this, "rows");

	}

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

	/**
	 * Required - Identifier for the search. This value is only returned for async
	 * and saved synchronous searches. For CSV, TSV, and TXT responses, this value
	 * is returned in the Async-ID HTTP header.
	 * 

* API name: {@code id} */ public final String id() { return this.id; } /** * Required - If true, the search is still running. If false, the * search has finished. This value is only returned for async and saved * synchronous searches. For CSV, TSV, and TXT responses, this value is returned * in the Async-partial HTTP header. *

* API name: {@code is_running} */ public final boolean isRunning() { return this.isRunning; } /** * Required - If true, the response does not contain complete * search results. If is_partial is true and * is_running is true, the search is still running. If * is_partial is true but is_running is * false, the results are partial due to a failure or timeout. This * value is only returned for async and saved synchronous searches. For CSV, * TSV, and TXT responses, this value is returned in the * Async-partial HTTP header. *

* API name: {@code is_partial} */ public final boolean isPartial() { return this.isPartial; } /** * Column headings for the search results. Each object is a column. *

* API name: {@code columns} */ public final List columns() { return this.columns; } /** * Cursor for the next set of paginated results. For CSV, TSV, and TXT * responses, this value is returned in the Cursor HTTP header. *

* API name: {@code cursor} */ @Nullable public final String cursor() { return this.cursor; } /** * Required - Values for the search results. *

* API name: {@code rows} */ public final List> rows() { return this.rows; } /** * 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("id"); generator.write(this.id); generator.writeKey("is_running"); generator.write(this.isRunning); generator.writeKey("is_partial"); generator.write(this.isPartial); if (ApiTypeHelper.isDefined(this.columns)) { generator.writeKey("columns"); generator.writeStartArray(); for (Column item0 : this.columns) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.cursor != null) { generator.writeKey("cursor"); generator.write(this.cursor); } if (ApiTypeHelper.isDefined(this.rows)) { generator.writeKey("rows"); generator.writeStartArray(); for (List item0 : this.rows) { generator.writeStartArray(); if (item0 != null) { for (JsonData item1 : item0) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link GetAsyncResponse}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { private String id; private Boolean isRunning; private Boolean isPartial; @Nullable private List columns; @Nullable private String cursor; private List> rows; /** * Required - Identifier for the search. This value is only returned for async * and saved synchronous searches. For CSV, TSV, and TXT responses, this value * is returned in the Async-ID HTTP header. *

* API name: {@code id} */ public final Builder id(String value) { this.id = value; return this; } /** * Required - If true, the search is still running. If false, the * search has finished. This value is only returned for async and saved * synchronous searches. For CSV, TSV, and TXT responses, this value is returned * in the Async-partial HTTP header. *

* API name: {@code is_running} */ public final Builder isRunning(boolean value) { this.isRunning = value; return this; } /** * Required - If true, the response does not contain complete * search results. If is_partial is true and * is_running is true, the search is still running. If * is_partial is true but is_running is * false, the results are partial due to a failure or timeout. This * value is only returned for async and saved synchronous searches. For CSV, * TSV, and TXT responses, this value is returned in the * Async-partial HTTP header. *

* API name: {@code is_partial} */ public final Builder isPartial(boolean value) { this.isPartial = value; return this; } /** * Column headings for the search results. Each object is a column. *

* API name: {@code columns} *

* Adds all elements of list to columns. */ public final Builder columns(List list) { this.columns = _listAddAll(this.columns, list); return this; } /** * Column headings for the search results. Each object is a column. *

* API name: {@code columns} *

* Adds one or more values to columns. */ public final Builder columns(Column value, Column... values) { this.columns = _listAdd(this.columns, value, values); return this; } /** * Column headings for the search results. Each object is a column. *

* API name: {@code columns} *

* Adds a value to columns using a builder lambda. */ public final Builder columns(Function> fn) { return columns(fn.apply(new Column.Builder()).build()); } /** * Cursor for the next set of paginated results. For CSV, TSV, and TXT * responses, this value is returned in the Cursor HTTP header. *

* API name: {@code cursor} */ public final Builder cursor(@Nullable String value) { this.cursor = value; return this; } /** * Required - Values for the search results. *

* API name: {@code rows} *

* Adds all elements of list to rows. */ public final Builder rows(List> list) { this.rows = _listAddAll(this.rows, list); return this; } /** * Required - Values for the search results. *

* API name: {@code rows} *

* Adds one or more values to rows. */ public final Builder rows(List value, List... values) { this.rows = _listAdd(this.rows, value, values); return this; } @Override protected Builder self() { return this; } /** * Builds a {@link GetAsyncResponse}. * * @throws NullPointerException * if some of the required fields are null. */ public GetAsyncResponse build() { _checkSingleUse(); return new GetAsyncResponse(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link GetAsyncResponse} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, GetAsyncResponse::setupGetAsyncResponseDeserializer); protected static void setupGetAsyncResponseDeserializer(ObjectDeserializer op) { op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); op.add(Builder::isRunning, JsonpDeserializer.booleanDeserializer(), "is_running"); op.add(Builder::isPartial, JsonpDeserializer.booleanDeserializer(), "is_partial"); op.add(Builder::columns, JsonpDeserializer.arrayDeserializer(Column._DESERIALIZER), "columns"); op.add(Builder::cursor, JsonpDeserializer.stringDeserializer(), "cursor"); op.add(Builder::rows, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER)), "rows"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy