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

co.elastic.clients.elasticsearch.cluster.stats.ClusterOperatingSystem 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.cluster.stats;

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

// typedef: cluster.stats.ClusterOperatingSystem

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class ClusterOperatingSystem implements JsonpSerializable {
	private final int allocatedProcessors;

	private final int availableProcessors;

	private final OperatingSystemMemoryInfo mem;

	private final List names;

	private final List prettyNames;

	private final List architectures;

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

	private ClusterOperatingSystem(Builder builder) {

		this.allocatedProcessors = ApiTypeHelper.requireNonNull(builder.allocatedProcessors, this,
				"allocatedProcessors");
		this.availableProcessors = ApiTypeHelper.requireNonNull(builder.availableProcessors, this,
				"availableProcessors");
		this.mem = ApiTypeHelper.requireNonNull(builder.mem, this, "mem");
		this.names = ApiTypeHelper.unmodifiableRequired(builder.names, this, "names");
		this.prettyNames = ApiTypeHelper.unmodifiableRequired(builder.prettyNames, this, "prettyNames");
		this.architectures = ApiTypeHelper.unmodifiable(builder.architectures);

	}

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

	/**
	 * Required - API name: {@code allocated_processors}
	 */
	public final int allocatedProcessors() {
		return this.allocatedProcessors;
	}

	/**
	 * Required - API name: {@code available_processors}
	 */
	public final int availableProcessors() {
		return this.availableProcessors;
	}

	/**
	 * Required - API name: {@code mem}
	 */
	public final OperatingSystemMemoryInfo mem() {
		return this.mem;
	}

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

	/**
	 * Required - API name: {@code pretty_names}
	 */
	public final List prettyNames() {
		return this.prettyNames;
	}

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

	/**
	 * 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("allocated_processors");
		generator.write(this.allocatedProcessors);

		generator.writeKey("available_processors");
		generator.write(this.availableProcessors);

		generator.writeKey("mem");
		this.mem.serialize(generator, mapper);

		if (ApiTypeHelper.isDefined(this.names)) {
			generator.writeKey("names");
			generator.writeStartArray();
			for (ClusterOperatingSystemName item0 : this.names) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.prettyNames)) {
			generator.writeKey("pretty_names");
			generator.writeStartArray();
			for (ClusterOperatingSystemPrettyName item0 : this.prettyNames) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.architectures)) {
			generator.writeKey("architectures");
			generator.writeStartArray();
			for (ClusterOperatingSystemArchitecture item0 : this.architectures) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}

	}

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

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

	public static class Builder extends WithJsonObjectBuilderBase
			implements
				ObjectBuilder {
		private Integer allocatedProcessors;

		private Integer availableProcessors;

		private OperatingSystemMemoryInfo mem;

		private List names;

		private List prettyNames;

		@Nullable
		private List architectures;

		/**
		 * Required - API name: {@code allocated_processors}
		 */
		public final Builder allocatedProcessors(int value) {
			this.allocatedProcessors = value;
			return this;
		}

		/**
		 * Required - API name: {@code available_processors}
		 */
		public final Builder availableProcessors(int value) {
			this.availableProcessors = value;
			return this;
		}

		/**
		 * Required - API name: {@code mem}
		 */
		public final Builder mem(OperatingSystemMemoryInfo value) {
			this.mem = value;
			return this;
		}

		/**
		 * Required - API name: {@code mem}
		 */
		public final Builder mem(
				Function> fn) {
			return this.mem(fn.apply(new OperatingSystemMemoryInfo.Builder()).build());
		}

		/**
		 * Required - API name: {@code names}
		 * 

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

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

* Adds a value to names using a builder lambda. */ public final Builder names( Function> fn) { return names(fn.apply(new ClusterOperatingSystemName.Builder()).build()); } /** * Required - API name: {@code pretty_names} *

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

* Adds one or more values to prettyNames. */ public final Builder prettyNames(ClusterOperatingSystemPrettyName value, ClusterOperatingSystemPrettyName... values) { this.prettyNames = _listAdd(this.prettyNames, value, values); return this; } /** * Required - API name: {@code pretty_names} *

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

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

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

* Adds a value to architectures using a builder lambda. */ public final Builder architectures( Function> fn) { return architectures(fn.apply(new ClusterOperatingSystemArchitecture.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link ClusterOperatingSystem}. * * @throws NullPointerException * if some of the required fields are null. */ public ClusterOperatingSystem build() { _checkSingleUse(); return new ClusterOperatingSystem(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link ClusterOperatingSystem} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, ClusterOperatingSystem::setupClusterOperatingSystemDeserializer); protected static void setupClusterOperatingSystemDeserializer( ObjectDeserializer op) { op.add(Builder::allocatedProcessors, JsonpDeserializer.integerDeserializer(), "allocated_processors"); op.add(Builder::availableProcessors, JsonpDeserializer.integerDeserializer(), "available_processors"); op.add(Builder::mem, OperatingSystemMemoryInfo._DESERIALIZER, "mem"); op.add(Builder::names, JsonpDeserializer.arrayDeserializer(ClusterOperatingSystemName._DESERIALIZER), "names"); op.add(Builder::prettyNames, JsonpDeserializer.arrayDeserializer(ClusterOperatingSystemPrettyName._DESERIALIZER), "pretty_names"); op.add(Builder::architectures, JsonpDeserializer.arrayDeserializer(ClusterOperatingSystemArchitecture._DESERIALIZER), "architectures"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy