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

co.elastic.clients.elasticsearch.tasks.ListRequest 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.tasks;

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: tasks.list.Request

/**
 * The task management API returns information about tasks currently executing
 * on one or more nodes in the cluster.
 * 
 * @see API
 *      specification
 */

public class ListRequest extends RequestBase {
	private final List actions;

	@Nullable
	private final Boolean detailed;

	@Nullable
	private final GroupBy groupBy;

	@Nullable
	private final Time masterTimeout;

	private final List nodeId;

	@Nullable
	private final String parentTaskId;

	@Nullable
	private final Time timeout;

	@Nullable
	private final Boolean waitForCompletion;

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

	private ListRequest(Builder builder) {

		this.actions = ApiTypeHelper.unmodifiable(builder.actions);
		this.detailed = builder.detailed;
		this.groupBy = builder.groupBy;
		this.masterTimeout = builder.masterTimeout;
		this.nodeId = ApiTypeHelper.unmodifiable(builder.nodeId);
		this.parentTaskId = builder.parentTaskId;
		this.timeout = builder.timeout;
		this.waitForCompletion = builder.waitForCompletion;

	}

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

	/**
	 * Comma-separated list or wildcard expression of actions used to limit the
	 * request.
	 * 

* API name: {@code actions} */ public final List actions() { return this.actions; } /** * If true, the response includes detailed information about shard * recoveries. *

* API name: {@code detailed} */ @Nullable public final Boolean detailed() { return this.detailed; } /** * Key used to group tasks in the response. *

* API name: {@code group_by} */ @Nullable public final GroupBy groupBy() { return this.groupBy; } /** * Period to wait for a connection to the master node. If no response is * received before the timeout expires, the request fails and returns an error. *

* API name: {@code master_timeout} */ @Nullable public final Time masterTimeout() { return this.masterTimeout; } /** * Comma-separated list of node IDs or names used to limit returned information. *

* API name: {@code node_id} */ public final List nodeId() { return this.nodeId; } /** * Parent task ID used to limit returned information. To return all tasks, omit * this parameter or use a value of -1. *

* API name: {@code parent_task_id} */ @Nullable public final String parentTaskId() { return this.parentTaskId; } /** * Period to wait for a response. If no response is received before the timeout * expires, the request fails and returns an error. *

* API name: {@code timeout} */ @Nullable public final Time timeout() { return this.timeout; } /** * If true, the request blocks until the operation is complete. *

* API name: {@code wait_for_completion} */ @Nullable public final Boolean waitForCompletion() { return this.waitForCompletion; } // --------------------------------------------------------------------------------------------- /** * Builder for {@link ListRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private List actions; @Nullable private Boolean detailed; @Nullable private GroupBy groupBy; @Nullable private Time masterTimeout; @Nullable private List nodeId; @Nullable private String parentTaskId; @Nullable private Time timeout; @Nullable private Boolean waitForCompletion; /** * Comma-separated list or wildcard expression of actions used to limit the * request. *

* API name: {@code actions} *

* Adds all elements of list to actions. */ public final Builder actions(List list) { this.actions = _listAddAll(this.actions, list); return this; } /** * Comma-separated list or wildcard expression of actions used to limit the * request. *

* API name: {@code actions} *

* Adds one or more values to actions. */ public final Builder actions(String value, String... values) { this.actions = _listAdd(this.actions, value, values); return this; } /** * If true, the response includes detailed information about shard * recoveries. *

* API name: {@code detailed} */ public final Builder detailed(@Nullable Boolean value) { this.detailed = value; return this; } /** * Key used to group tasks in the response. *

* API name: {@code group_by} */ public final Builder groupBy(@Nullable GroupBy value) { this.groupBy = value; return this; } /** * Period to wait for a connection to the master node. If no response is * received before the timeout expires, the request fails and returns an error. *

* API name: {@code master_timeout} */ public final Builder masterTimeout(@Nullable Time value) { this.masterTimeout = value; return this; } /** * Period to wait for a connection to the master node. If no response is * received before the timeout expires, the request fails and returns an error. *

* API name: {@code master_timeout} */ public final Builder masterTimeout(Function> fn) { return this.masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Comma-separated list of node IDs or names used to limit returned information. *

* API name: {@code node_id} *

* Adds all elements of list to nodeId. */ public final Builder nodeId(List list) { this.nodeId = _listAddAll(this.nodeId, list); return this; } /** * Comma-separated list of node IDs or names used to limit returned information. *

* API name: {@code node_id} *

* Adds one or more values to nodeId. */ public final Builder nodeId(String value, String... values) { this.nodeId = _listAdd(this.nodeId, value, values); return this; } /** * Parent task ID used to limit returned information. To return all tasks, omit * this parameter or use a value of -1. *

* API name: {@code parent_task_id} */ public final Builder parentTaskId(@Nullable String value) { this.parentTaskId = value; return this; } /** * Period to wait for a response. If no response is received before the timeout * expires, the request fails and returns an error. *

* API name: {@code timeout} */ public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; } /** * Period to wait for a response. If no response is received before the timeout * expires, the request fails and returns an error. *

* API name: {@code timeout} */ public final Builder timeout(Function> fn) { return this.timeout(fn.apply(new Time.Builder()).build()); } /** * If true, the request blocks until the operation is complete. *

* API name: {@code wait_for_completion} */ public final Builder waitForCompletion(@Nullable Boolean value) { this.waitForCompletion = value; return this; } /** * Builds a {@link ListRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public ListRequest build() { _checkSingleUse(); return new ListRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code tasks.list}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/tasks.list", // Request method request -> { return "GET"; }, // Request path request -> { return "/_tasks"; }, // Request parameters request -> { Map params = new HashMap<>(); if (request.masterTimeout != null) { params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.parentTaskId != null) { params.put("parent_task_id", request.parentTaskId); } if (request.detailed != null) { params.put("detailed", String.valueOf(request.detailed)); } if (request.groupBy != null) { params.put("group_by", request.groupBy.jsonValue()); } if (ApiTypeHelper.isDefined(request.actions)) { params.put("actions", request.actions.stream().map(v -> v).collect(Collectors.joining(","))); } if (request.waitForCompletion != null) { params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } if (ApiTypeHelper.isDefined(request.nodeId)) { params.put("node_id", request.nodeId.stream().map(v -> v).collect(Collectors.joining(","))); } return params; }, SimpleEndpoint.emptyMap(), false, ListResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy