software.amazon.awssdk.services.rolesanywhere.model.SubjectDetail Maven / Gradle / Ivy
Show all versions of rolesanywhere Show documentation
/*
* 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.rolesanywhere.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The state of the subject after a read or write operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SubjectDetail implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CREATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("createdAt")
.getter(getter(SubjectDetail::createdAt))
.setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField> CREDENTIALS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("credentials")
.getter(getter(SubjectDetail::credentials))
.setter(setter(Builder::credentials))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("credentials").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(CredentialSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("enabled").getter(getter(SubjectDetail::enabled)).setter(setter(Builder::enabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("enabled").build()).build();
private static final SdkField> INSTANCE_PROPERTIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("instanceProperties")
.getter(getter(SubjectDetail::instanceProperties))
.setter(setter(Builder::instanceProperties))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("instanceProperties").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(InstanceProperty::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField LAST_SEEN_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("lastSeenAt")
.getter(getter(SubjectDetail::lastSeenAt))
.setter(setter(Builder::lastSeenAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastSeenAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField SUBJECT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("subjectArn").getter(getter(SubjectDetail::subjectArn)).setter(setter(Builder::subjectArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("subjectArn").build()).build();
private static final SdkField SUBJECT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("subjectId").getter(getter(SubjectDetail::subjectId)).setter(setter(Builder::subjectId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("subjectId").build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("updatedAt")
.getter(getter(SubjectDetail::updatedAt))
.setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("updatedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField X509_SUBJECT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("x509Subject").getter(getter(SubjectDetail::x509Subject)).setter(setter(Builder::x509Subject))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("x509Subject").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CREATED_AT_FIELD,
CREDENTIALS_FIELD, ENABLED_FIELD, INSTANCE_PROPERTIES_FIELD, LAST_SEEN_AT_FIELD, SUBJECT_ARN_FIELD, SUBJECT_ID_FIELD,
UPDATED_AT_FIELD, X509_SUBJECT_FIELD));
private static final long serialVersionUID = 1L;
private final Instant createdAt;
private final List credentials;
private final Boolean enabled;
private final List instanceProperties;
private final Instant lastSeenAt;
private final String subjectArn;
private final String subjectId;
private final Instant updatedAt;
private final String x509Subject;
private SubjectDetail(BuilderImpl builder) {
this.createdAt = builder.createdAt;
this.credentials = builder.credentials;
this.enabled = builder.enabled;
this.instanceProperties = builder.instanceProperties;
this.lastSeenAt = builder.lastSeenAt;
this.subjectArn = builder.subjectArn;
this.subjectId = builder.subjectId;
this.updatedAt = builder.updatedAt;
this.x509Subject = builder.x509Subject;
}
/**
*
* The ISO-8601 timestamp when the subject was created.
*
*
* @return The ISO-8601 timestamp when the subject was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
* For responses, this returns true if the service returned a value for the Credentials property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasCredentials() {
return credentials != null && !(credentials instanceof SdkAutoConstructList);
}
/**
*
* The temporary session credentials vended at the last authenticating call with this subject.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasCredentials} method.
*
*
* @return The temporary session credentials vended at the last authenticating call with this subject.
*/
public final List credentials() {
return credentials;
}
/**
*
* The enabled status of the subject.
*
*
* @return The enabled status of the subject.
*/
public final Boolean enabled() {
return enabled;
}
/**
* For responses, this returns true if the service returned a value for the InstanceProperties property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasInstanceProperties() {
return instanceProperties != null && !(instanceProperties instanceof SdkAutoConstructList);
}
/**
*
* The specified instance properties associated with the request.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasInstanceProperties} method.
*
*
* @return The specified instance properties associated with the request.
*/
public final List instanceProperties() {
return instanceProperties;
}
/**
*
* The ISO-8601 timestamp of the last time this subject requested temporary session credentials.
*
*
* @return The ISO-8601 timestamp of the last time this subject requested temporary session credentials.
*/
public final Instant lastSeenAt() {
return lastSeenAt;
}
/**
*
* The ARN of the resource.
*
*
* @return The ARN of the resource.
*/
public final String subjectArn() {
return subjectArn;
}
/**
*
* The id of the resource
*
*
* @return The id of the resource
*/
public final String subjectId() {
return subjectId;
}
/**
*
* The ISO-8601 timestamp when the subject was last updated.
*
*
* @return The ISO-8601 timestamp when the subject was last updated.
*/
public final Instant updatedAt() {
return updatedAt;
}
/**
*
* The x509 principal identifier of the authenticating certificate.
*
*
* @return The x509 principal identifier of the authenticating certificate.
*/
public final String x509Subject() {
return x509Subject;
}
@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(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(hasCredentials() ? credentials() : null);
hashCode = 31 * hashCode + Objects.hashCode(enabled());
hashCode = 31 * hashCode + Objects.hashCode(hasInstanceProperties() ? instanceProperties() : null);
hashCode = 31 * hashCode + Objects.hashCode(lastSeenAt());
hashCode = 31 * hashCode + Objects.hashCode(subjectArn());
hashCode = 31 * hashCode + Objects.hashCode(subjectId());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
hashCode = 31 * hashCode + Objects.hashCode(x509Subject());
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 SubjectDetail)) {
return false;
}
SubjectDetail other = (SubjectDetail) obj;
return Objects.equals(createdAt(), other.createdAt()) && hasCredentials() == other.hasCredentials()
&& Objects.equals(credentials(), other.credentials()) && Objects.equals(enabled(), other.enabled())
&& hasInstanceProperties() == other.hasInstanceProperties()
&& Objects.equals(instanceProperties(), other.instanceProperties())
&& Objects.equals(lastSeenAt(), other.lastSeenAt()) && Objects.equals(subjectArn(), other.subjectArn())
&& Objects.equals(subjectId(), other.subjectId()) && Objects.equals(updatedAt(), other.updatedAt())
&& Objects.equals(x509Subject(), other.x509Subject());
}
/**
* 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("SubjectDetail").add("CreatedAt", createdAt())
.add("Credentials", hasCredentials() ? credentials() : null).add("Enabled", enabled())
.add("InstanceProperties", hasInstanceProperties() ? instanceProperties() : null).add("LastSeenAt", lastSeenAt())
.add("SubjectArn", subjectArn()).add("SubjectId", subjectId()).add("UpdatedAt", updatedAt())
.add("X509Subject", x509Subject()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "credentials":
return Optional.ofNullable(clazz.cast(credentials()));
case "enabled":
return Optional.ofNullable(clazz.cast(enabled()));
case "instanceProperties":
return Optional.ofNullable(clazz.cast(instanceProperties()));
case "lastSeenAt":
return Optional.ofNullable(clazz.cast(lastSeenAt()));
case "subjectArn":
return Optional.ofNullable(clazz.cast(subjectArn()));
case "subjectId":
return Optional.ofNullable(clazz.cast(subjectId()));
case "updatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
case "x509Subject":
return Optional.ofNullable(clazz.cast(x509Subject()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function