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

co.elastic.clients.elasticsearch.tasks.TaskListResponseBase 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.
 */

package co.elastic.clients.elasticsearch.tasks;

import co.elastic.clients.elasticsearch._types.ErrorCause;
import co.elastic.clients.elasticsearch._types.TaskFailure;
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.JsonpUtils;
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.String;
import java.util.List;
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: tasks._types.TaskListResponseBase

/**
 *
 * @see API
 *      specification
 */

public abstract class TaskListResponseBase implements JsonpSerializable {
	private final List nodeFailures;

	private final List taskFailures;

	private final Map nodes;

	@Nullable
	private final TaskInfos tasks;

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

	protected TaskListResponseBase(AbstractBuilder builder) {

		this.nodeFailures = ApiTypeHelper.unmodifiable(builder.nodeFailures);
		this.taskFailures = ApiTypeHelper.unmodifiable(builder.taskFailures);
		this.nodes = ApiTypeHelper.unmodifiable(builder.nodes);
		this.tasks = builder.tasks;

	}

	/**
	 * API name: {@code node_failures}
	 */
	public final List nodeFailures() {
		return this.nodeFailures;
	}

	/**
	 * API name: {@code task_failures}
	 */
	public final List taskFailures() {
		return this.taskFailures;
	}

	/**
	 * Task information grouped by node, if group_by was set to
	 * node (the default).
	 * 

* API name: {@code nodes} */ public final Map nodes() { return this.nodes; } /** * Either a flat list of tasks if group_by was set to * none, or grouped by parents if group_by was set to * parents. *

* API name: {@code tasks} */ @Nullable public final TaskInfos tasks() { return this.tasks; } /** * 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.nodeFailures)) { generator.writeKey("node_failures"); generator.writeStartArray(); for (ErrorCause item0 : this.nodeFailures) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.taskFailures)) { generator.writeKey("task_failures"); generator.writeStartArray(); for (TaskFailure item0 : this.taskFailures) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.nodes)) { generator.writeKey("nodes"); generator.writeStartObject(); for (Map.Entry item0 : this.nodes.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.tasks != null) { generator.writeKey("tasks"); this.tasks.serialize(generator, mapper); } } @Override public String toString() { return JsonpUtils.toString(this); } public abstract static class AbstractBuilder> extends WithJsonObjectBuilderBase { @Nullable private List nodeFailures; @Nullable private List taskFailures; @Nullable private Map nodes; @Nullable private TaskInfos tasks; /** * API name: {@code node_failures} *

* Adds all elements of list to nodeFailures. */ public final BuilderT nodeFailures(List list) { this.nodeFailures = _listAddAll(this.nodeFailures, list); return self(); } /** * API name: {@code node_failures} *

* Adds one or more values to nodeFailures. */ public final BuilderT nodeFailures(ErrorCause value, ErrorCause... values) { this.nodeFailures = _listAdd(this.nodeFailures, value, values); return self(); } /** * API name: {@code node_failures} *

* Adds a value to nodeFailures using a builder lambda. */ public final BuilderT nodeFailures(Function> fn) { return nodeFailures(fn.apply(new ErrorCause.Builder()).build()); } /** * API name: {@code task_failures} *

* Adds all elements of list to taskFailures. */ public final BuilderT taskFailures(List list) { this.taskFailures = _listAddAll(this.taskFailures, list); return self(); } /** * API name: {@code task_failures} *

* Adds one or more values to taskFailures. */ public final BuilderT taskFailures(TaskFailure value, TaskFailure... values) { this.taskFailures = _listAdd(this.taskFailures, value, values); return self(); } /** * API name: {@code task_failures} *

* Adds a value to taskFailures using a builder lambda. */ public final BuilderT taskFailures(Function> fn) { return taskFailures(fn.apply(new TaskFailure.Builder()).build()); } /** * Task information grouped by node, if group_by was set to * node (the default). *

* API name: {@code nodes} *

* Adds all entries of map to nodes. */ public final BuilderT nodes(Map map) { this.nodes = _mapPutAll(this.nodes, map); return self(); } /** * Task information grouped by node, if group_by was set to * node (the default). *

* API name: {@code nodes} *

* Adds an entry to nodes. */ public final BuilderT nodes(String key, NodeTasks value) { this.nodes = _mapPut(this.nodes, key, value); return self(); } /** * Task information grouped by node, if group_by was set to * node (the default). *

* API name: {@code nodes} *

* Adds an entry to nodes using a builder lambda. */ public final BuilderT nodes(String key, Function> fn) { return nodes(key, fn.apply(new NodeTasks.Builder()).build()); } /** * Either a flat list of tasks if group_by was set to * none, or grouped by parents if group_by was set to * parents. *

* API name: {@code tasks} */ public final BuilderT tasks(@Nullable TaskInfos value) { this.tasks = value; return self(); } /** * Either a flat list of tasks if group_by was set to * none, or grouped by parents if group_by was set to * parents. *

* API name: {@code tasks} */ public final BuilderT tasks(Function> fn) { return this.tasks(fn.apply(new TaskInfos.Builder()).build()); } protected abstract BuilderT self(); } // --------------------------------------------------------------------------------------------- protected static > void setupTaskListResponseBaseDeserializer( ObjectDeserializer op) { op.add(AbstractBuilder::nodeFailures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "node_failures"); op.add(AbstractBuilder::taskFailures, JsonpDeserializer.arrayDeserializer(TaskFailure._DESERIALIZER), "task_failures"); op.add(AbstractBuilder::nodes, JsonpDeserializer.stringMapDeserializer(NodeTasks._DESERIALIZER), "nodes"); op.add(AbstractBuilder::tasks, TaskInfos._DESERIALIZER, "tasks"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy