software.amazon.awssdk.services.iotsitewise.model.Identity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iotsitewise Show documentation
Show all versions of iotsitewise Show documentation
The AWS Java SDK for Io T Site Wise module holds the client classes that are used for
communicating with Io T Site Wise.
/*
* 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