
software.amazon.awssdk.services.rbin.model.CreateRuleResponse 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.rbin.model;
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.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateRuleResponse extends RbinResponse implements
ToCopyableBuilder {
private static final SdkField IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Identifier").getter(getter(CreateRuleResponse::identifier)).setter(setter(Builder::identifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Identifier").build()).build();
private static final SdkField RETENTION_PERIOD_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RetentionPeriod")
.getter(getter(CreateRuleResponse::retentionPeriod)).setter(setter(Builder::retentionPeriod))
.constructor(RetentionPeriod::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RetentionPeriod").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(CreateRuleResponse::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateRuleResponse::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceType").getter(getter(CreateRuleResponse::resourceTypeAsString))
.setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceType").build()).build();
private static final SdkField> RESOURCE_TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ResourceTags")
.getter(getter(CreateRuleResponse::resourceTags))
.setter(setter(Builder::resourceTags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceTags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ResourceTag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(CreateRuleResponse::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField LOCK_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("LockConfiguration")
.getter(getter(CreateRuleResponse::lockConfiguration)).setter(setter(Builder::lockConfiguration))
.constructor(LockConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LockConfiguration").build()).build();
private static final SdkField LOCK_STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LockState").getter(getter(CreateRuleResponse::lockStateAsString)).setter(setter(Builder::lockState))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LockState").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IDENTIFIER_FIELD,
RETENTION_PERIOD_FIELD, DESCRIPTION_FIELD, TAGS_FIELD, RESOURCE_TYPE_FIELD, RESOURCE_TAGS_FIELD, STATUS_FIELD,
LOCK_CONFIGURATION_FIELD, LOCK_STATE_FIELD));
private final String identifier;
private final RetentionPeriod retentionPeriod;
private final String description;
private final List tags;
private final String resourceType;
private final List resourceTags;
private final String status;
private final LockConfiguration lockConfiguration;
private final String lockState;
private CreateRuleResponse(BuilderImpl builder) {
super(builder);
this.identifier = builder.identifier;
this.retentionPeriod = builder.retentionPeriod;
this.description = builder.description;
this.tags = builder.tags;
this.resourceType = builder.resourceType;
this.resourceTags = builder.resourceTags;
this.status = builder.status;
this.lockConfiguration = builder.lockConfiguration;
this.lockState = builder.lockState;
}
/**
*
* The unique ID of the retention rule.
*
*
* @return The unique ID of the retention rule.
*/
public final String identifier() {
return identifier;
}
/**
* Returns the value of the RetentionPeriod property for this object.
*
* @return The value of the RetentionPeriod property for this object.
*/
public final RetentionPeriod retentionPeriod() {
return retentionPeriod;
}
/**
*
* The retention rule description.
*
*
* @return The retention rule description.
*/
public final String description() {
return description;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* Information about the tags assigned to the retention rule.
*
*
* 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 #hasTags} method.
*
*
* @return Information about the tags assigned to the retention rule.
*/
public final List tags() {
return tags;
}
/**
*
* The resource type retained by the retention rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resourceTypeAsString}.
*
*
* @return The resource type retained by the retention rule.
* @see ResourceType
*/
public final ResourceType resourceType() {
return ResourceType.fromValue(resourceType);
}
/**
*
* The resource type retained by the retention rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resourceTypeAsString}.
*
*
* @return The resource type retained by the retention rule.
* @see ResourceType
*/
public final String resourceTypeAsString() {
return resourceType;
}
/**
* For responses, this returns true if the service returned a value for the ResourceTags 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 hasResourceTags() {
return resourceTags != null && !(resourceTags instanceof SdkAutoConstructList);
}
/**
*
* Information about the resource tags used to identify resources that are retained by the retention rule.
*
*
* 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 #hasResourceTags} method.
*
*
* @return Information about the resource tags used to identify resources that are retained by the retention rule.
*/
public final List resourceTags() {
return resourceTags;
}
/**
*
* The state of the retention rule. Only retention rules that are in the available
state retain
* resources.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link RuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The state of the retention rule. Only retention rules that are in the available
state retain
* resources.
* @see RuleStatus
*/
public final RuleStatus status() {
return RuleStatus.fromValue(status);
}
/**
*
* The state of the retention rule. Only retention rules that are in the available
state retain
* resources.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link RuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The state of the retention rule. Only retention rules that are in the available
state retain
* resources.
* @see RuleStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* Information about the retention rule lock configuration.
*
*
* @return Information about the retention rule lock configuration.
*/
public final LockConfiguration lockConfiguration() {
return lockConfiguration;
}
/**
*
* The lock state for the retention rule.
*
*
* -
*
* locked
- The retention rule is locked and can't be modified or deleted.
*
*
* -
*
* pending_unlock
- The retention rule has been unlocked but it is still within the unlock delay
* period. The retention rule can be modified or deleted only after the unlock delay period has expired.
*
*
* -
*
* unlocked
- The retention rule is unlocked and it can be modified or deleted by any user with the
* required permissions.
*
*
* -
*
* null
- The retention rule has never been locked. Once a retention rule has been locked, it can
* transition between the locked
and unlocked
states only; it can never transition back to
* null
.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #lockState} will
* return {@link LockState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #lockStateAsString}.
*
*
* @return The lock state for the retention rule.
*
* -
*
* locked
- The retention rule is locked and can't be modified or deleted.
*
*
* -
*
* pending_unlock
- The retention rule has been unlocked but it is still within the unlock
* delay period. The retention rule can be modified or deleted only after the unlock delay period has
* expired.
*
*
* -
*
* unlocked
- The retention rule is unlocked and it can be modified or deleted by any user with
* the required permissions.
*
*
* -
*
* null
- The retention rule has never been locked. Once a retention rule has been locked, it
* can transition between the locked
and unlocked
states only; it can never
* transition back to null
.
*
*
* @see LockState
*/
public final LockState lockState() {
return LockState.fromValue(lockState);
}
/**
*
* The lock state for the retention rule.
*
*
* -
*
* locked
- The retention rule is locked and can't be modified or deleted.
*
*
* -
*
* pending_unlock
- The retention rule has been unlocked but it is still within the unlock delay
* period. The retention rule can be modified or deleted only after the unlock delay period has expired.
*
*
* -
*
* unlocked
- The retention rule is unlocked and it can be modified or deleted by any user with the
* required permissions.
*
*
* -
*
* null
- The retention rule has never been locked. Once a retention rule has been locked, it can
* transition between the locked
and unlocked
states only; it can never transition back to
* null
.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #lockState} will
* return {@link LockState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #lockStateAsString}.
*
*
* @return The lock state for the retention rule.
*
* -
*
* locked
- The retention rule is locked and can't be modified or deleted.
*
*
* -
*
* pending_unlock
- The retention rule has been unlocked but it is still within the unlock
* delay period. The retention rule can be modified or deleted only after the unlock delay period has
* expired.
*
*
* -
*
* unlocked
- The retention rule is unlocked and it can be modified or deleted by any user with
* the required permissions.
*
*
* -
*
* null
- The retention rule has never been locked. Once a retention rule has been locked, it
* can transition between the locked
and unlocked
states only; it can never
* transition back to null
.
*
*
* @see LockState
*/
public final String lockStateAsString() {
return lockState;
}
@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(identifier());
hashCode = 31 * hashCode + Objects.hashCode(retentionPeriod());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(resourceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasResourceTags() ? resourceTags() : null);
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(lockConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(lockStateAsString());
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 CreateRuleResponse)) {
return false;
}
CreateRuleResponse other = (CreateRuleResponse) obj;
return Objects.equals(identifier(), other.identifier()) && Objects.equals(retentionPeriod(), other.retentionPeriod())
&& Objects.equals(description(), other.description()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags()) && Objects.equals(resourceTypeAsString(), other.resourceTypeAsString())
&& hasResourceTags() == other.hasResourceTags() && Objects.equals(resourceTags(), other.resourceTags())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(lockConfiguration(), other.lockConfiguration())
&& Objects.equals(lockStateAsString(), other.lockStateAsString());
}
/**
* 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("CreateRuleResponse").add("Identifier", identifier()).add("RetentionPeriod", retentionPeriod())
.add("Description", description()).add("Tags", hasTags() ? tags() : null)
.add("ResourceType", resourceTypeAsString()).add("ResourceTags", hasResourceTags() ? resourceTags() : null)
.add("Status", statusAsString()).add("LockConfiguration", lockConfiguration())
.add("LockState", lockStateAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Identifier":
return Optional.ofNullable(clazz.cast(identifier()));
case "RetentionPeriod":
return Optional.ofNullable(clazz.cast(retentionPeriod()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "ResourceType":
return Optional.ofNullable(clazz.cast(resourceTypeAsString()));
case "ResourceTags":
return Optional.ofNullable(clazz.cast(resourceTags()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "LockConfiguration":
return Optional.ofNullable(clazz.cast(lockConfiguration()));
case "LockState":
return Optional.ofNullable(clazz.cast(lockStateAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function