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

software.amazon.awssdk.services.iotsitewise.model.Identity Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Io T Site Wise module holds the client classes that are used for communicating with Io T Site Wise.

There is a newer version: 2.28.4
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.services.iotsitewise.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Contains an identity that can access an IoT SiteWise Monitor resource. *

* *

* Currently, you can't use Amazon Web Services API operations to retrieve IAM Identity Center identity IDs. You can * find the IAM Identity Center identity IDs in the URL of user and group pages in the IAM Identity Center console. *

*
*/ @Generated("software.amazon.awssdk:codegen") public final class Identity implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField USER_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("user").getter(getter(Identity::user)).setter(setter(Builder::user)).constructor(UserIdentity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("user").build()).build(); private static final SdkField GROUP_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("group").getter(getter(Identity::group)).setter(setter(Builder::group)) .constructor(GroupIdentity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("group").build()).build(); private static final SdkField IAM_USER_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("iamUser").getter(getter(Identity::iamUser)).setter(setter(Builder::iamUser)) .constructor(IAMUserIdentity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("iamUser").build()).build(); private static final SdkField IAM_ROLE_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("iamRole").getter(getter(Identity::iamRole)).setter(setter(Builder::iamRole)) .constructor(IAMRoleIdentity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("iamRole").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(USER_FIELD, GROUP_FIELD, IAM_USER_FIELD, IAM_ROLE_FIELD)); private static final long serialVersionUID = 1L; private final UserIdentity user; private final GroupIdentity group; private final IAMUserIdentity iamUser; private final IAMRoleIdentity iamRole; private Identity(BuilderImpl builder) { this.user = builder.user; this.group = builder.group; this.iamUser = builder.iamUser; this.iamRole = builder.iamRole; } /** *

* An IAM Identity Center user identity. *

* * @return An IAM Identity Center user identity. */ public final UserIdentity user() { return user; } /** *

* An IAM Identity Center group identity. *

* * @return An IAM Identity Center group identity. */ public final GroupIdentity group() { return group; } /** *

* An IAM user identity. *

* * @return An IAM user identity. */ public final IAMUserIdentity iamUser() { return iamUser; } /** *

* An IAM role identity. *

* * @return An IAM role identity. */ public final IAMRoleIdentity iamRole() { return iamRole; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(user()); hashCode = 31 * hashCode + Objects.hashCode(group()); hashCode = 31 * hashCode + Objects.hashCode(iamUser()); hashCode = 31 * hashCode + Objects.hashCode(iamRole()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Identity)) { return false; } Identity other = (Identity) obj; return Objects.equals(user(), other.user()) && Objects.equals(group(), other.group()) && Objects.equals(iamUser(), other.iamUser()) && Objects.equals(iamRole(), other.iamRole()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("Identity").add("User", user()).add("Group", group()).add("IamUser", iamUser()) .add("IamRole", iamRole()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "user": return Optional.ofNullable(clazz.cast(user())); case "group": return Optional.ofNullable(clazz.cast(group())); case "iamUser": return Optional.ofNullable(clazz.cast(iamUser())); case "iamRole": return Optional.ofNullable(clazz.cast(iamRole())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Identity) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* An IAM Identity Center user identity. *

* * @param user * An IAM Identity Center user identity. * @return Returns a reference to this object so that method calls can be chained together. */ Builder user(UserIdentity user); /** *

* An IAM Identity Center user identity. *

* This is a convenience method that creates an instance of the {@link UserIdentity.Builder} avoiding the need * to create one manually via {@link UserIdentity#builder()}. * *

* When the {@link Consumer} completes, {@link UserIdentity.Builder#build()} is called immediately and its * result is passed to {@link #user(UserIdentity)}. * * @param user * a consumer that will call methods on {@link UserIdentity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #user(UserIdentity) */ default Builder user(Consumer user) { return user(UserIdentity.builder().applyMutation(user).build()); } /** *

* An IAM Identity Center group identity. *

* * @param group * An IAM Identity Center group identity. * @return Returns a reference to this object so that method calls can be chained together. */ Builder group(GroupIdentity group); /** *

* An IAM Identity Center group identity. *

* This is a convenience method that creates an instance of the {@link GroupIdentity.Builder} avoiding the need * to create one manually via {@link GroupIdentity#builder()}. * *

* When the {@link Consumer} completes, {@link GroupIdentity.Builder#build()} is called immediately and its * result is passed to {@link #group(GroupIdentity)}. * * @param group * a consumer that will call methods on {@link GroupIdentity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #group(GroupIdentity) */ default Builder group(Consumer group) { return group(GroupIdentity.builder().applyMutation(group).build()); } /** *

* An IAM user identity. *

* * @param iamUser * An IAM user identity. * @return Returns a reference to this object so that method calls can be chained together. */ Builder iamUser(IAMUserIdentity iamUser); /** *

* An IAM user identity. *

* This is a convenience method that creates an instance of the {@link IAMUserIdentity.Builder} avoiding the * need to create one manually via {@link IAMUserIdentity#builder()}. * *

* When the {@link Consumer} completes, {@link IAMUserIdentity.Builder#build()} is called immediately and its * result is passed to {@link #iamUser(IAMUserIdentity)}. * * @param iamUser * a consumer that will call methods on {@link IAMUserIdentity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #iamUser(IAMUserIdentity) */ default Builder iamUser(Consumer iamUser) { return iamUser(IAMUserIdentity.builder().applyMutation(iamUser).build()); } /** *

* An IAM role identity. *

* * @param iamRole * An IAM role identity. * @return Returns a reference to this object so that method calls can be chained together. */ Builder iamRole(IAMRoleIdentity iamRole); /** *

* An IAM role identity. *

* This is a convenience method that creates an instance of the {@link IAMRoleIdentity.Builder} avoiding the * need to create one manually via {@link IAMRoleIdentity#builder()}. * *

* When the {@link Consumer} completes, {@link IAMRoleIdentity.Builder#build()} is called immediately and its * result is passed to {@link #iamRole(IAMRoleIdentity)}. * * @param iamRole * a consumer that will call methods on {@link IAMRoleIdentity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #iamRole(IAMRoleIdentity) */ default Builder iamRole(Consumer iamRole) { return iamRole(IAMRoleIdentity.builder().applyMutation(iamRole).build()); } } static final class BuilderImpl implements Builder { private UserIdentity user; private GroupIdentity group; private IAMUserIdentity iamUser; private IAMRoleIdentity iamRole; private BuilderImpl() { } private BuilderImpl(Identity model) { user(model.user); group(model.group); iamUser(model.iamUser); iamRole(model.iamRole); } public final UserIdentity.Builder getUser() { return user != null ? user.toBuilder() : null; } public final void setUser(UserIdentity.BuilderImpl user) { this.user = user != null ? user.build() : null; } @Override public final Builder user(UserIdentity user) { this.user = user; return this; } public final GroupIdentity.Builder getGroup() { return group != null ? group.toBuilder() : null; } public final void setGroup(GroupIdentity.BuilderImpl group) { this.group = group != null ? group.build() : null; } @Override public final Builder group(GroupIdentity group) { this.group = group; return this; } public final IAMUserIdentity.Builder getIamUser() { return iamUser != null ? iamUser.toBuilder() : null; } public final void setIamUser(IAMUserIdentity.BuilderImpl iamUser) { this.iamUser = iamUser != null ? iamUser.build() : null; } @Override public final Builder iamUser(IAMUserIdentity iamUser) { this.iamUser = iamUser; return this; } public final IAMRoleIdentity.Builder getIamRole() { return iamRole != null ? iamRole.toBuilder() : null; } public final void setIamRole(IAMRoleIdentity.BuilderImpl iamRole) { this.iamRole = iamRole != null ? iamRole.build() : null; } @Override public final Builder iamRole(IAMRoleIdentity iamRole) { this.iamRole = iamRole; return this; } @Override public Identity build() { return new Identity(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy