
software.amazon.awssdk.services.managedblockchain.model.Invitation 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.managedblockchain.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.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.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An invitation to an Amazon Web Services account to create a member and join the network.
*
*
* Applies only to Hyperledger Fabric.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Invitation implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField INVITATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InvitationId").getter(getter(Invitation::invitationId)).setter(setter(Builder::invitationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InvitationId").build()).build();
private static final SdkField CREATION_DATE_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreationDate")
.getter(getter(Invitation::creationDate))
.setter(setter(Builder::creationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationDate").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField EXPIRATION_DATE_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("ExpirationDate")
.getter(getter(Invitation::expirationDate))
.setter(setter(Builder::expirationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpirationDate").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(Invitation::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField NETWORK_SUMMARY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("NetworkSummary")
.getter(getter(Invitation::networkSummary)).setter(setter(Builder::networkSummary))
.constructor(NetworkSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NetworkSummary").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(Invitation::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INVITATION_ID_FIELD,
CREATION_DATE_FIELD, EXPIRATION_DATE_FIELD, STATUS_FIELD, NETWORK_SUMMARY_FIELD, ARN_FIELD));
private static final long serialVersionUID = 1L;
private final String invitationId;
private final Instant creationDate;
private final Instant expirationDate;
private final String status;
private final NetworkSummary networkSummary;
private final String arn;
private Invitation(BuilderImpl builder) {
this.invitationId = builder.invitationId;
this.creationDate = builder.creationDate;
this.expirationDate = builder.expirationDate;
this.status = builder.status;
this.networkSummary = builder.networkSummary;
this.arn = builder.arn;
}
/**
*
* The unique identifier for the invitation.
*
*
* @return The unique identifier for the invitation.
*/
public final String invitationId() {
return invitationId;
}
/**
*
* The date and time that the invitation was created.
*
*
* @return The date and time that the invitation was created.
*/
public final Instant creationDate() {
return creationDate;
}
/**
*
* The date and time that the invitation expires. This is the CreationDate
plus the
* ProposalDurationInHours
that is specified in the ProposalThresholdPolicy
. After this
* date and time, the invitee can no longer create a member and join the network using this
* InvitationId
.
*
*
* @return The date and time that the invitation expires. This is the CreationDate
plus the
* ProposalDurationInHours
that is specified in the ProposalThresholdPolicy
. After
* this date and time, the invitee can no longer create a member and join the network using this
* InvitationId
.
*/
public final Instant expirationDate() {
return expirationDate;
}
/**
*
* The status of the invitation:
*
*
* -
*
* PENDING
- The invitee hasn't created a member to join the network, and the invitation hasn't yet
* expired.
*
*
* -
*
* ACCEPTING
- The invitee has begun creating a member, and creation hasn't yet completed.
*
*
* -
*
* ACCEPTED
- The invitee created a member and joined the network using the InvitationID
.
*
*
* -
*
* REJECTED
- The invitee rejected the invitation.
*
*
* -
*
* EXPIRED
- The invitee neither created a member nor rejected the invitation before the
* ExpirationDate
.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link InvitationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the invitation:
*
* -
*
* PENDING
- The invitee hasn't created a member to join the network, and the invitation hasn't
* yet expired.
*
*
* -
*
* ACCEPTING
- The invitee has begun creating a member, and creation hasn't yet completed.
*
*
* -
*
* ACCEPTED
- The invitee created a member and joined the network using the
* InvitationID
.
*
*
* -
*
* REJECTED
- The invitee rejected the invitation.
*
*
* -
*
* EXPIRED
- The invitee neither created a member nor rejected the invitation before the
* ExpirationDate
.
*
*
* @see InvitationStatus
*/
public final InvitationStatus status() {
return InvitationStatus.fromValue(status);
}
/**
*
* The status of the invitation:
*
*
* -
*
* PENDING
- The invitee hasn't created a member to join the network, and the invitation hasn't yet
* expired.
*
*
* -
*
* ACCEPTING
- The invitee has begun creating a member, and creation hasn't yet completed.
*
*
* -
*
* ACCEPTED
- The invitee created a member and joined the network using the InvitationID
.
*
*
* -
*
* REJECTED
- The invitee rejected the invitation.
*
*
* -
*
* EXPIRED
- The invitee neither created a member nor rejected the invitation before the
* ExpirationDate
.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link InvitationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the invitation:
*
* -
*
* PENDING
- The invitee hasn't created a member to join the network, and the invitation hasn't
* yet expired.
*
*
* -
*
* ACCEPTING
- The invitee has begun creating a member, and creation hasn't yet completed.
*
*
* -
*
* ACCEPTED
- The invitee created a member and joined the network using the
* InvitationID
.
*
*
* -
*
* REJECTED
- The invitee rejected the invitation.
*
*
* -
*
* EXPIRED
- The invitee neither created a member nor rejected the invitation before the
* ExpirationDate
.
*
*
* @see InvitationStatus
*/
public final String statusAsString() {
return status;
}
/**
* Returns the value of the NetworkSummary property for this object.
*
* @return The value of the NetworkSummary property for this object.
*/
public final NetworkSummary networkSummary() {
return networkSummary;
}
/**
*
* The Amazon Resource Name (ARN) of the invitation. For more information about ARNs and their format, see Amazon Resource Names
* (ARNs) in the Amazon Web Services General Reference.
*
*
* @return The Amazon Resource Name (ARN) of the invitation. For more information about ARNs and their format, see
* Amazon Resource
* Names (ARNs) in the Amazon Web Services General Reference.
*/
public final String arn() {
return arn;
}
@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(invitationId());
hashCode = 31 * hashCode + Objects.hashCode(creationDate());
hashCode = 31 * hashCode + Objects.hashCode(expirationDate());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(networkSummary());
hashCode = 31 * hashCode + Objects.hashCode(arn());
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 Invitation)) {
return false;
}
Invitation other = (Invitation) obj;
return Objects.equals(invitationId(), other.invitationId()) && Objects.equals(creationDate(), other.creationDate())
&& Objects.equals(expirationDate(), other.expirationDate())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(networkSummary(), other.networkSummary()) && Objects.equals(arn(), other.arn());
}
/**
* 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("Invitation").add("InvitationId", invitationId()).add("CreationDate", creationDate())
.add("ExpirationDate", expirationDate()).add("Status", statusAsString()).add("NetworkSummary", networkSummary())
.add("Arn", arn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InvitationId":
return Optional.ofNullable(clazz.cast(invitationId()));
case "CreationDate":
return Optional.ofNullable(clazz.cast(creationDate()));
case "ExpirationDate":
return Optional.ofNullable(clazz.cast(expirationDate()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "NetworkSummary":
return Optional.ofNullable(clazz.cast(networkSummary()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function