
software.amazon.awssdk.services.ram.model.Principal Maven / Gradle / Ivy
/*
* 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.ram.model;
import java.io.Serializable;
import java.time.Instant;
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.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;
/**
*
* Describes a principal for use with Resource Access Manager.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Principal implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(Principal::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField RESOURCE_SHARE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resourceShareArn").getter(getter(Principal::resourceShareArn)).setter(setter(Builder::resourceShareArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceShareArn").build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("creationTime").getter(getter(Principal::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationTime").build()).build();
private static final SdkField LAST_UPDATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("lastUpdatedTime").getter(getter(Principal::lastUpdatedTime)).setter(setter(Builder::lastUpdatedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdatedTime").build()).build();
private static final SdkField EXTERNAL_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("external").getter(getter(Principal::external)).setter(setter(Builder::external))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("external").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD,
RESOURCE_SHARE_ARN_FIELD, CREATION_TIME_FIELD, LAST_UPDATED_TIME_FIELD, EXTERNAL_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String resourceShareArn;
private final Instant creationTime;
private final Instant lastUpdatedTime;
private final Boolean external;
private Principal(BuilderImpl builder) {
this.id = builder.id;
this.resourceShareArn = builder.resourceShareArn;
this.creationTime = builder.creationTime;
this.lastUpdatedTime = builder.lastUpdatedTime;
this.external = builder.external;
}
/**
*
* The ID of the principal that can be associated with a resource share.
*
*
* @return The ID of the principal that can be associated with a resource share.
*/
public final String id() {
return id;
}
/**
*
* The Amazon Resource Name
* (ARN) of a resource share the principal is associated with.
*
*
* @return The Amazon Resource
* Name (ARN) of a resource share the principal is associated with.
*/
public final String resourceShareArn() {
return resourceShareArn;
}
/**
*
* The date and time when the principal was associated with the resource share.
*
*
* @return The date and time when the principal was associated with the resource share.
*/
public final Instant creationTime() {
return creationTime;
}
/**
*
* The date and time when the association between the resource share and the principal was last updated.
*
*
* @return The date and time when the association between the resource share and the principal was last updated.
*/
public final Instant lastUpdatedTime() {
return lastUpdatedTime;
}
/**
*
* Indicates the relationship between the Amazon Web Services account the principal belongs to and the account that
* owns the resource share:
*
*
* -
*
* True
– The two accounts belong to same organization.
*
*
* -
*
* False
– The two accounts do not belong to the same organization.
*
*
*
*
* @return Indicates the relationship between the Amazon Web Services account the principal belongs to and the
* account that owns the resource share:
*
* -
*
* True
– The two accounts belong to same organization.
*
*
* -
*
* False
– The two accounts do not belong to the same organization.
*
*
*/
public final Boolean external() {
return external;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(resourceShareArn());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTime());
hashCode = 31 * hashCode + Objects.hashCode(external());
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 Principal)) {
return false;
}
Principal other = (Principal) obj;
return Objects.equals(id(), other.id()) && Objects.equals(resourceShareArn(), other.resourceShareArn())
&& Objects.equals(creationTime(), other.creationTime())
&& Objects.equals(lastUpdatedTime(), other.lastUpdatedTime()) && Objects.equals(external(), other.external());
}
/**
* 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("Principal").add("Id", id()).add("ResourceShareArn", resourceShareArn())
.add("CreationTime", creationTime()).add("LastUpdatedTime", lastUpdatedTime()).add("External", external())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "resourceShareArn":
return Optional.ofNullable(clazz.cast(resourceShareArn()));
case "creationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "lastUpdatedTime":
return Optional.ofNullable(clazz.cast(lastUpdatedTime()));
case "external":
return Optional.ofNullable(clazz.cast(external()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function