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

co.elastic.clients.elasticsearch.tasks.NodeTasks 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.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.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: tasks._types.NodeTasks

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class NodeTasks implements JsonpSerializable {
	@Nullable
	private final String name;

	@Nullable
	private final String transportAddress;

	@Nullable
	private final String host;

	@Nullable
	private final String ip;

	private final List roles;

	private final Map attributes;

	private final Map tasks;

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

	private NodeTasks(Builder builder) {

		this.name = builder.name;
		this.transportAddress = builder.transportAddress;
		this.host = builder.host;
		this.ip = builder.ip;
		this.roles = ApiTypeHelper.unmodifiable(builder.roles);
		this.attributes = ApiTypeHelper.unmodifiable(builder.attributes);
		this.tasks = ApiTypeHelper.unmodifiableRequired(builder.tasks, this, "tasks");

	}

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

	/**
	 * API name: {@code name}
	 */
	@Nullable
	public final String name() {
		return this.name;
	}

	/**
	 * API name: {@code transport_address}
	 */
	@Nullable
	public final String transportAddress() {
		return this.transportAddress;
	}

	/**
	 * API name: {@code host}
	 */
	@Nullable
	public final String host() {
		return this.host;
	}

	/**
	 * API name: {@code ip}
	 */
	@Nullable
	public final String ip() {
		return this.ip;
	}

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

	/**
	 * API name: {@code attributes}
	 */
	public final Map attributes() {
		return this.attributes;
	}

	/**
	 * Required - API name: {@code tasks}
	 */
	public final Map 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 (this.name != null) {
			generator.writeKey("name");
			generator.write(this.name);

		}
		if (this.transportAddress != null) {
			generator.writeKey("transport_address");
			generator.write(this.transportAddress);

		}
		if (this.host != null) {
			generator.writeKey("host");
			generator.write(this.host);

		}
		if (this.ip != null) {
			generator.writeKey("ip");
			generator.write(this.ip);

		}
		if (ApiTypeHelper.isDefined(this.roles)) {
			generator.writeKey("roles");
			generator.writeStartArray();
			for (String item0 : this.roles) {
				generator.write(item0);

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.attributes)) {
			generator.writeKey("attributes");
			generator.writeStartObject();
			for (Map.Entry item0 : this.attributes.entrySet()) {
				generator.writeKey(item0.getKey());
				generator.write(item0.getValue());

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.tasks)) {
			generator.writeKey("tasks");
			generator.writeStartObject();
			for (Map.Entry item0 : this.tasks.entrySet()) {
				generator.writeKey(item0.getKey());
				item0.getValue().serialize(generator, mapper);

			}
			generator.writeEnd();

		}

	}

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

	/**
	 * Builder for {@link NodeTasks}.
	 */

	public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder {
		@Nullable
		private String name;

		@Nullable
		private String transportAddress;

		@Nullable
		private String host;

		@Nullable
		private String ip;

		@Nullable
		private List roles;

		@Nullable
		private Map attributes;

		private Map tasks;

		/**
		 * API name: {@code name}
		 */
		public final Builder name(@Nullable String value) {
			this.name = value;
			return this;
		}

		/**
		 * API name: {@code transport_address}
		 */
		public final Builder transportAddress(@Nullable String value) {
			this.transportAddress = value;
			return this;
		}

		/**
		 * API name: {@code host}
		 */
		public final Builder host(@Nullable String value) {
			this.host = value;
			return this;
		}

		/**
		 * API name: {@code ip}
		 */
		public final Builder ip(@Nullable String value) {
			this.ip = value;
			return this;
		}

		/**
		 * API name: {@code roles}
		 * 

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

* Adds one or more values to roles. */ public final Builder roles(String value, String... values) { this.roles = _listAdd(this.roles, value, values); return this; } /** * API name: {@code attributes} *

* Adds all entries of map to attributes. */ public final Builder attributes(Map map) { this.attributes = _mapPutAll(this.attributes, map); return this; } /** * API name: {@code attributes} *

* Adds an entry to attributes. */ public final Builder attributes(String key, String value) { this.attributes = _mapPut(this.attributes, key, value); return this; } /** * Required - API name: {@code tasks} *

* Adds all entries of map to tasks. */ public final Builder tasks(Map map) { this.tasks = _mapPutAll(this.tasks, map); return this; } /** * Required - API name: {@code tasks} *

* Adds an entry to tasks. */ public final Builder tasks(String key, TaskInfo value) { this.tasks = _mapPut(this.tasks, key, value); return this; } /** * Required - API name: {@code tasks} *

* Adds an entry to tasks using a builder lambda. */ public final Builder tasks(String key, Function> fn) { return tasks(key, fn.apply(new TaskInfo.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link NodeTasks}. * * @throws NullPointerException * if some of the required fields are null. */ public NodeTasks build() { _checkSingleUse(); return new NodeTasks(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link NodeTasks} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, NodeTasks::setupNodeTasksDeserializer); protected static void setupNodeTasksDeserializer(ObjectDeserializer op) { op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); op.add(Builder::host, JsonpDeserializer.stringDeserializer(), "host"); op.add(Builder::ip, JsonpDeserializer.stringDeserializer(), "ip"); op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "roles"); op.add(Builder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); op.add(Builder::tasks, JsonpDeserializer.stringMapDeserializer(TaskInfo._DESERIALIZER), "tasks"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy