software.amazon.awssdk.services.drs.model.PITPolicyRule Maven / Gradle / Ivy
Show all versions of drs 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.drs.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.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;
/**
*
* A rule in the Point in Time (PIT) policy representing when to take snapshots and how long to retain them for.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PITPolicyRule implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("enabled").getter(getter(PITPolicyRule::enabled)).setter(setter(Builder::enabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("enabled").build()).build();
private static final SdkField INTERVAL_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("interval").getter(getter(PITPolicyRule::interval)).setter(setter(Builder::interval))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("interval").build()).build();
private static final SdkField RETENTION_DURATION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("retentionDuration").getter(getter(PITPolicyRule::retentionDuration))
.setter(setter(Builder::retentionDuration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("retentionDuration").build()).build();
private static final SdkField RULE_ID_FIELD = SdkField. builder(MarshallingType.LONG).memberName("ruleID")
.getter(getter(PITPolicyRule::ruleID)).setter(setter(Builder::ruleID))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ruleID").build()).build();
private static final SdkField UNITS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("units")
.getter(getter(PITPolicyRule::unitsAsString)).setter(setter(Builder::units))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("units").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENABLED_FIELD, INTERVAL_FIELD,
RETENTION_DURATION_FIELD, RULE_ID_FIELD, UNITS_FIELD));
private static final long serialVersionUID = 1L;
private final Boolean enabled;
private final Integer interval;
private final Integer retentionDuration;
private final Long ruleID;
private final String units;
private PITPolicyRule(BuilderImpl builder) {
this.enabled = builder.enabled;
this.interval = builder.interval;
this.retentionDuration = builder.retentionDuration;
this.ruleID = builder.ruleID;
this.units = builder.units;
}
/**
*
* Whether this rule is enabled or not.
*
*
* @return Whether this rule is enabled or not.
*/
public final Boolean enabled() {
return enabled;
}
/**
*
* How often, in the chosen units, a snapshot should be taken.
*
*
* @return How often, in the chosen units, a snapshot should be taken.
*/
public final Integer interval() {
return interval;
}
/**
*
* The duration to retain a snapshot for, in the chosen units.
*
*
* @return The duration to retain a snapshot for, in the chosen units.
*/
public final Integer retentionDuration() {
return retentionDuration;
}
/**
*
* The ID of the rule.
*
*
* @return The ID of the rule.
*/
public final Long ruleID() {
return ruleID;
}
/**
*
* The units used to measure the interval and retentionDuration.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #units} will return
* {@link PITPolicyRuleUnits#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #unitsAsString}.
*
*
* @return The units used to measure the interval and retentionDuration.
* @see PITPolicyRuleUnits
*/
public final PITPolicyRuleUnits units() {
return PITPolicyRuleUnits.fromValue(units);
}
/**
*
* The units used to measure the interval and retentionDuration.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #units} will return
* {@link PITPolicyRuleUnits#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #unitsAsString}.
*
*
* @return The units used to measure the interval and retentionDuration.
* @see PITPolicyRuleUnits
*/
public final String unitsAsString() {
return units;
}
@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(enabled());
hashCode = 31 * hashCode + Objects.hashCode(interval());
hashCode = 31 * hashCode + Objects.hashCode(retentionDuration());
hashCode = 31 * hashCode + Objects.hashCode(ruleID());
hashCode = 31 * hashCode + Objects.hashCode(unitsAsString());
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 PITPolicyRule)) {
return false;
}
PITPolicyRule other = (PITPolicyRule) obj;
return Objects.equals(enabled(), other.enabled()) && Objects.equals(interval(), other.interval())
&& Objects.equals(retentionDuration(), other.retentionDuration()) && Objects.equals(ruleID(), other.ruleID())
&& Objects.equals(unitsAsString(), other.unitsAsString());
}
/**
* 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("PITPolicyRule").add("Enabled", enabled()).add("Interval", interval())
.add("RetentionDuration", retentionDuration()).add("RuleID", ruleID()).add("Units", unitsAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "enabled":
return Optional.ofNullable(clazz.cast(enabled()));
case "interval":
return Optional.ofNullable(clazz.cast(interval()));
case "retentionDuration":
return Optional.ofNullable(clazz.cast(retentionDuration()));
case "ruleID":
return Optional.ofNullable(clazz.cast(ruleID()));
case "units":
return Optional.ofNullable(clazz.cast(unitsAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function