
software.amazon.awssdk.services.iotanalytics.model.Channel 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.iotanalytics.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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A collection of data from an MQTT topic. Channels archive the raw, unprocessed messages before publishing the data to
* a pipeline.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Channel implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Channel::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField STORAGE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(Channel::storage)).setter(setter(Builder::storage)).constructor(ChannelStorage::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("storage").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Channel::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Channel::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField RETENTION_PERIOD_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(Channel::retentionPeriod))
.setter(setter(Builder::retentionPeriod)).constructor(RetentionPeriod::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("retentionPeriod").build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Channel::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationTime").build()).build();
private static final SdkField LAST_UPDATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Channel::lastUpdateTime)).setter(setter(Builder::lastUpdateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdateTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, STORAGE_FIELD,
ARN_FIELD, STATUS_FIELD, RETENTION_PERIOD_FIELD, CREATION_TIME_FIELD, LAST_UPDATE_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final ChannelStorage storage;
private final String arn;
private final String status;
private final RetentionPeriod retentionPeriod;
private final Instant creationTime;
private final Instant lastUpdateTime;
private Channel(BuilderImpl builder) {
this.name = builder.name;
this.storage = builder.storage;
this.arn = builder.arn;
this.status = builder.status;
this.retentionPeriod = builder.retentionPeriod;
this.creationTime = builder.creationTime;
this.lastUpdateTime = builder.lastUpdateTime;
}
/**
*
* The name of the channel.
*
*
* @return The name of the channel.
*/
public String name() {
return name;
}
/**
*
* Where channel data is stored. You may choose one of "serviceManagedS3" or "customerManagedS3" storage. If not
* specified, the default is "serviceManagedS3". This cannot be changed after creation of the channel.
*
*
* @return Where channel data is stored. You may choose one of "serviceManagedS3" or "customerManagedS3" storage. If
* not specified, the default is "serviceManagedS3". This cannot be changed after creation of the channel.
*/
public ChannelStorage storage() {
return storage;
}
/**
*
* The ARN of the channel.
*
*
* @return The ARN of the channel.
*/
public String arn() {
return arn;
}
/**
*
* The status of the channel.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ChannelStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the channel.
* @see ChannelStatus
*/
public ChannelStatus status() {
return ChannelStatus.fromValue(status);
}
/**
*
* The status of the channel.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ChannelStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the channel.
* @see ChannelStatus
*/
public String statusAsString() {
return status;
}
/**
*
* How long, in days, message data is kept for the channel.
*
*
* @return How long, in days, message data is kept for the channel.
*/
public RetentionPeriod retentionPeriod() {
return retentionPeriod;
}
/**
*
* When the channel was created.
*
*
* @return When the channel was created.
*/
public Instant creationTime() {
return creationTime;
}
/**
*
* When the channel was last updated.
*
*
* @return When the channel was last updated.
*/
public Instant lastUpdateTime() {
return lastUpdateTime;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(storage());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(retentionPeriod());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdateTime());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Channel)) {
return false;
}
Channel other = (Channel) obj;
return Objects.equals(name(), other.name()) && Objects.equals(storage(), other.storage())
&& Objects.equals(arn(), other.arn()) && Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(retentionPeriod(), other.retentionPeriod())
&& Objects.equals(creationTime(), other.creationTime())
&& Objects.equals(lastUpdateTime(), other.lastUpdateTime());
}
/**
* 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 String toString() {
return ToString.builder("Channel").add("Name", name()).add("Storage", storage()).add("Arn", arn())
.add("Status", statusAsString()).add("RetentionPeriod", retentionPeriod()).add("CreationTime", creationTime())
.add("LastUpdateTime", lastUpdateTime()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "storage":
return Optional.ofNullable(clazz.cast(storage()));
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "retentionPeriod":
return Optional.ofNullable(clazz.cast(retentionPeriod()));
case "creationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "lastUpdateTime":
return Optional.ofNullable(clazz.cast(lastUpdateTime()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function