software.amazon.awssdk.services.backup.model.GetLegalHoldResponse Maven / Gradle / Ivy
Show all versions of backup 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.backup.model;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class GetLegalHoldResponse extends BackupResponse implements
ToCopyableBuilder {
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Title")
.getter(getter(GetLegalHoldResponse::title)).setter(setter(Builder::title))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Title").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(GetLegalHoldResponse::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(GetLegalHoldResponse::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField CANCEL_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CancelDescription").getter(getter(GetLegalHoldResponse::cancelDescription))
.setter(setter(Builder::cancelDescription))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CancelDescription").build()).build();
private static final SdkField LEGAL_HOLD_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LegalHoldId").getter(getter(GetLegalHoldResponse::legalHoldId)).setter(setter(Builder::legalHoldId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LegalHoldId").build()).build();
private static final SdkField LEGAL_HOLD_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LegalHoldArn").getter(getter(GetLegalHoldResponse::legalHoldArn)).setter(setter(Builder::legalHoldArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LegalHoldArn").build()).build();
private static final SdkField CREATION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreationDate").getter(getter(GetLegalHoldResponse::creationDate)).setter(setter(Builder::creationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationDate").build()).build();
private static final SdkField CANCELLATION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CancellationDate").getter(getter(GetLegalHoldResponse::cancellationDate))
.setter(setter(Builder::cancellationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CancellationDate").build()).build();
private static final SdkField RETAIN_RECORD_UNTIL_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("RetainRecordUntil").getter(getter(GetLegalHoldResponse::retainRecordUntil))
.setter(setter(Builder::retainRecordUntil))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RetainRecordUntil").build()).build();
private static final SdkField RECOVERY_POINT_SELECTION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RecoveryPointSelection")
.getter(getter(GetLegalHoldResponse::recoveryPointSelection)).setter(setter(Builder::recoveryPointSelection))
.constructor(RecoveryPointSelection::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecoveryPointSelection").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TITLE_FIELD, STATUS_FIELD,
DESCRIPTION_FIELD, CANCEL_DESCRIPTION_FIELD, LEGAL_HOLD_ID_FIELD, LEGAL_HOLD_ARN_FIELD, CREATION_DATE_FIELD,
CANCELLATION_DATE_FIELD, RETAIN_RECORD_UNTIL_FIELD, RECOVERY_POINT_SELECTION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private final String title;
private final String status;
private final String description;
private final String cancelDescription;
private final String legalHoldId;
private final String legalHoldArn;
private final Instant creationDate;
private final Instant cancellationDate;
private final Instant retainRecordUntil;
private final RecoveryPointSelection recoveryPointSelection;
private GetLegalHoldResponse(BuilderImpl builder) {
super(builder);
this.title = builder.title;
this.status = builder.status;
this.description = builder.description;
this.cancelDescription = builder.cancelDescription;
this.legalHoldId = builder.legalHoldId;
this.legalHoldArn = builder.legalHoldArn;
this.creationDate = builder.creationDate;
this.cancellationDate = builder.cancellationDate;
this.retainRecordUntil = builder.retainRecordUntil;
this.recoveryPointSelection = builder.recoveryPointSelection;
}
/**
*
* The title of the legal hold.
*
*
* @return The title of the legal hold.
*/
public final String title() {
return title;
}
/**
*
* The status of the legal hold.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link LegalHoldStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the legal hold.
* @see LegalHoldStatus
*/
public final LegalHoldStatus status() {
return LegalHoldStatus.fromValue(status);
}
/**
*
* The status of the legal hold.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link LegalHoldStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the legal hold.
* @see LegalHoldStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The description of the legal hold.
*
*
* @return The description of the legal hold.
*/
public final String description() {
return description;
}
/**
*
* The reason for removing the legal hold.
*
*
* @return The reason for removing the legal hold.
*/
public final String cancelDescription() {
return cancelDescription;
}
/**
*
* The ID of the legal hold.
*
*
* @return The ID of the legal hold.
*/
public final String legalHoldId() {
return legalHoldId;
}
/**
*
* The framework ARN for the specified legal hold. The format of the ARN depends on the resource type.
*
*
* @return The framework ARN for the specified legal hold. The format of the ARN depends on the resource type.
*/
public final String legalHoldArn() {
return legalHoldArn;
}
/**
*
* The time when the legal hold was created.
*
*
* @return The time when the legal hold was created.
*/
public final Instant creationDate() {
return creationDate;
}
/**
*
* The time when the legal hold was cancelled.
*
*
* @return The time when the legal hold was cancelled.
*/
public final Instant cancellationDate() {
return cancellationDate;
}
/**
*
* The date and time until which the legal hold record is retained.
*
*
* @return The date and time until which the legal hold record is retained.
*/
public final Instant retainRecordUntil() {
return retainRecordUntil;
}
/**
*
* The criteria to assign a set of resources, such as resource types or backup vaults.
*
*
* @return The criteria to assign a set of resources, such as resource types or backup vaults.
*/
public final RecoveryPointSelection recoveryPointSelection() {
return recoveryPointSelection;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(cancelDescription());
hashCode = 31 * hashCode + Objects.hashCode(legalHoldId());
hashCode = 31 * hashCode + Objects.hashCode(legalHoldArn());
hashCode = 31 * hashCode + Objects.hashCode(creationDate());
hashCode = 31 * hashCode + Objects.hashCode(cancellationDate());
hashCode = 31 * hashCode + Objects.hashCode(retainRecordUntil());
hashCode = 31 * hashCode + Objects.hashCode(recoveryPointSelection());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetLegalHoldResponse)) {
return false;
}
GetLegalHoldResponse other = (GetLegalHoldResponse) obj;
return Objects.equals(title(), other.title()) && Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(description(), other.description())
&& Objects.equals(cancelDescription(), other.cancelDescription())
&& Objects.equals(legalHoldId(), other.legalHoldId()) && Objects.equals(legalHoldArn(), other.legalHoldArn())
&& Objects.equals(creationDate(), other.creationDate())
&& Objects.equals(cancellationDate(), other.cancellationDate())
&& Objects.equals(retainRecordUntil(), other.retainRecordUntil())
&& Objects.equals(recoveryPointSelection(), other.recoveryPointSelection());
}
/**
* 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("GetLegalHoldResponse").add("Title", title()).add("Status", statusAsString())
.add("Description", description()).add("CancelDescription", cancelDescription())
.add("LegalHoldId", legalHoldId()).add("LegalHoldArn", legalHoldArn()).add("CreationDate", creationDate())
.add("CancellationDate", cancellationDate()).add("RetainRecordUntil", retainRecordUntil())
.add("RecoveryPointSelection", recoveryPointSelection()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Title":
return Optional.ofNullable(clazz.cast(title()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "CancelDescription":
return Optional.ofNullable(clazz.cast(cancelDescription()));
case "LegalHoldId":
return Optional.ofNullable(clazz.cast(legalHoldId()));
case "LegalHoldArn":
return Optional.ofNullable(clazz.cast(legalHoldArn()));
case "CreationDate":
return Optional.ofNullable(clazz.cast(creationDate()));
case "CancellationDate":
return Optional.ofNullable(clazz.cast(cancellationDate()));
case "RetainRecordUntil":
return Optional.ofNullable(clazz.cast(retainRecordUntil()));
case "RecoveryPointSelection":
return Optional.ofNullable(clazz.cast(recoveryPointSelection()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("Title", TITLE_FIELD);
map.put("Status", STATUS_FIELD);
map.put("Description", DESCRIPTION_FIELD);
map.put("CancelDescription", CANCEL_DESCRIPTION_FIELD);
map.put("LegalHoldId", LEGAL_HOLD_ID_FIELD);
map.put("LegalHoldArn", LEGAL_HOLD_ARN_FIELD);
map.put("CreationDate", CREATION_DATE_FIELD);
map.put("CancellationDate", CANCELLATION_DATE_FIELD);
map.put("RetainRecordUntil", RETAIN_RECORD_UNTIL_FIELD);
map.put("RecoveryPointSelection", RECOVERY_POINT_SELECTION_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function