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

co.elastic.clients.elasticsearch.security.UserProfile 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.security;

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

// typedef: security._types.UserProfile

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

	private final User user;

	private final Map data;

	private final Map access;

	@Nullable
	private final Boolean enabled;

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

	protected UserProfile(AbstractBuilder builder) {

		this.uid = ApiTypeHelper.requireNonNull(builder.uid, this, "uid");
		this.user = ApiTypeHelper.requireNonNull(builder.user, this, "user");
		this.data = ApiTypeHelper.unmodifiable(builder.data);
		this.access = ApiTypeHelper.unmodifiable(builder.access);
		this.enabled = builder.enabled;

	}

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

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

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

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

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

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

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

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

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

			}
			generator.writeEnd();

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

			}
			generator.writeEnd();

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

		}

	}

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

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

	public static class Builder extends UserProfile.AbstractBuilder implements ObjectBuilder {
		@Override
		protected Builder self() {
			return this;
		}

		/**
		 * Builds a {@link UserProfile}.
		 *
		 * @throws NullPointerException
		 *             if some of the required fields are null.
		 */
		public UserProfile build() {
			_checkSingleUse();

			return new UserProfile(this);
		}
	}

	protected abstract static class AbstractBuilder>
			extends
				WithJsonObjectBuilderBase {
		private String uid;

		private User user;

		@Nullable
		private Map data;

		@Nullable
		private Map access;

		@Nullable
		private Boolean enabled;

		/**
		 * Required - API name: {@code uid}
		 */
		public final BuilderT uid(String value) {
			this.uid = value;
			return self();
		}

		/**
		 * Required - API name: {@code user}
		 */
		public final BuilderT user(User value) {
			this.user = value;
			return self();
		}

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

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

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

* Adds an entry to data. */ public final BuilderT data(String key, JsonData value) { this.data = _mapPut(this.data, key, value); return self(); } /** * API name: {@code access} *

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

* Adds an entry to access. */ public final BuilderT access(String key, JsonData value) { this.access = _mapPut(this.access, key, value); return self(); } /** * API name: {@code enabled} */ public final BuilderT enabled(@Nullable Boolean value) { this.enabled = value; return self(); } protected abstract BuilderT self(); } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link UserProfile} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, UserProfile::setupUserProfileDeserializer); protected static > void setupUserProfileDeserializer( ObjectDeserializer op) { op.add(AbstractBuilder::uid, JsonpDeserializer.stringDeserializer(), "uid"); op.add(AbstractBuilder::user, User._DESERIALIZER, "user"); op.add(AbstractBuilder::data, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "data"); op.add(AbstractBuilder::access, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "access"); op.add(AbstractBuilder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy