software.amazon.awssdk.services.cloudwatchevents.model.Archive Maven / Gradle / Ivy
Show all versions of cloudwatchevents 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.cloudwatchevents.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;
/**
*
* An Archive
object that contains details about an archive.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Archive implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ARCHIVE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ArchiveName").getter(getter(Archive::archiveName)).setter(setter(Builder::archiveName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ArchiveName").build()).build();
private static final SdkField EVENT_SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EventSourceArn").getter(getter(Archive::eventSourceArn)).setter(setter(Builder::eventSourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventSourceArn").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(Archive::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateReason").getter(getter(Archive::stateReason)).setter(setter(Builder::stateReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateReason").build()).build();
private static final SdkField RETENTION_DAYS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("RetentionDays").getter(getter(Archive::retentionDays)).setter(setter(Builder::retentionDays))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RetentionDays").build()).build();
private static final SdkField SIZE_BYTES_FIELD = SdkField. builder(MarshallingType.LONG).memberName("SizeBytes")
.getter(getter(Archive::sizeBytes)).setter(setter(Builder::sizeBytes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SizeBytes").build()).build();
private static final SdkField EVENT_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("EventCount").getter(getter(Archive::eventCount)).setter(setter(Builder::eventCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventCount").build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreationTime").getter(getter(Archive::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARCHIVE_NAME_FIELD,
EVENT_SOURCE_ARN_FIELD, STATE_FIELD, STATE_REASON_FIELD, RETENTION_DAYS_FIELD, SIZE_BYTES_FIELD, EVENT_COUNT_FIELD,
CREATION_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String archiveName;
private final String eventSourceArn;
private final String state;
private final String stateReason;
private final Integer retentionDays;
private final Long sizeBytes;
private final Long eventCount;
private final Instant creationTime;
private Archive(BuilderImpl builder) {
this.archiveName = builder.archiveName;
this.eventSourceArn = builder.eventSourceArn;
this.state = builder.state;
this.stateReason = builder.stateReason;
this.retentionDays = builder.retentionDays;
this.sizeBytes = builder.sizeBytes;
this.eventCount = builder.eventCount;
this.creationTime = builder.creationTime;
}
/**
*
* The name of the archive.
*
*
* @return The name of the archive.
*/
public final String archiveName() {
return archiveName;
}
/**
*
* The ARN of the event bus associated with the archive. Only events from this event bus are sent to the archive.
*
*
* @return The ARN of the event bus associated with the archive. Only events from this event bus are sent to the
* archive.
*/
public final String eventSourceArn() {
return eventSourceArn;
}
/**
*
* The current state of the archive.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ArchiveState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The current state of the archive.
* @see ArchiveState
*/
public final ArchiveState state() {
return ArchiveState.fromValue(state);
}
/**
*
* The current state of the archive.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ArchiveState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The current state of the archive.
* @see ArchiveState
*/
public final String stateAsString() {
return state;
}
/**
*
* A description for the reason that the archive is in the current state.
*
*
* @return A description for the reason that the archive is in the current state.
*/
public final String stateReason() {
return stateReason;
}
/**
*
* The number of days to retain events in the archive before they are deleted.
*
*
* @return The number of days to retain events in the archive before they are deleted.
*/
public final Integer retentionDays() {
return retentionDays;
}
/**
*
* The size of the archive, in bytes.
*
*
* @return The size of the archive, in bytes.
*/
public final Long sizeBytes() {
return sizeBytes;
}
/**
*
* The number of events in the archive.
*
*
* @return The number of events in the archive.
*/
public final Long eventCount() {
return eventCount;
}
/**
*
* The time stamp for the time that the archive was created.
*
*
* @return The time stamp for the time that the archive was created.
*/
public final Instant creationTime() {
return creationTime;
}
@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(archiveName());
hashCode = 31 * hashCode + Objects.hashCode(eventSourceArn());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateReason());
hashCode = 31 * hashCode + Objects.hashCode(retentionDays());
hashCode = 31 * hashCode + Objects.hashCode(sizeBytes());
hashCode = 31 * hashCode + Objects.hashCode(eventCount());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
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 Archive)) {
return false;
}
Archive other = (Archive) obj;
return Objects.equals(archiveName(), other.archiveName()) && Objects.equals(eventSourceArn(), other.eventSourceArn())
&& Objects.equals(stateAsString(), other.stateAsString()) && Objects.equals(stateReason(), other.stateReason())
&& Objects.equals(retentionDays(), other.retentionDays()) && Objects.equals(sizeBytes(), other.sizeBytes())
&& Objects.equals(eventCount(), other.eventCount()) && Objects.equals(creationTime(), other.creationTime());
}
/**
* 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("Archive").add("ArchiveName", archiveName()).add("EventSourceArn", eventSourceArn())
.add("State", stateAsString()).add("StateReason", stateReason()).add("RetentionDays", retentionDays())
.add("SizeBytes", sizeBytes()).add("EventCount", eventCount()).add("CreationTime", creationTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ArchiveName":
return Optional.ofNullable(clazz.cast(archiveName()));
case "EventSourceArn":
return Optional.ofNullable(clazz.cast(eventSourceArn()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateReason":
return Optional.ofNullable(clazz.cast(stateReason()));
case "RetentionDays":
return Optional.ofNullable(clazz.cast(retentionDays()));
case "SizeBytes":
return Optional.ofNullable(clazz.cast(sizeBytes()));
case "EventCount":
return Optional.ofNullable(clazz.cast(eventCount()));
case "CreationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function