software.amazon.awssdk.services.kinesis.model.ConsumerDescription Maven / Gradle / Ivy
Show all versions of kinesis 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.kinesis.model;
import java.io.Serializable;
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.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 object that represents the details of a registered consumer. This type of object is returned by
* DescribeStreamConsumer.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ConsumerDescription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField CONSUMER_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ConsumerName").getter(getter(ConsumerDescription::consumerName)).setter(setter(Builder::consumerName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConsumerName").build()).build();
private static final SdkField CONSUMER_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ConsumerARN").getter(getter(ConsumerDescription::consumerARN)).setter(setter(Builder::consumerARN))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConsumerARN").build()).build();
private static final SdkField CONSUMER_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ConsumerStatus").getter(getter(ConsumerDescription::consumerStatusAsString))
.setter(setter(Builder::consumerStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConsumerStatus").build()).build();
private static final SdkField CONSUMER_CREATION_TIMESTAMP_FIELD = SdkField
. builder(MarshallingType.INSTANT).memberName("ConsumerCreationTimestamp")
.getter(getter(ConsumerDescription::consumerCreationTimestamp)).setter(setter(Builder::consumerCreationTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConsumerCreationTimestamp").build())
.build();
private static final SdkField STREAM_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StreamARN").getter(getter(ConsumerDescription::streamARN)).setter(setter(Builder::streamARN))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StreamARN").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONSUMER_NAME_FIELD,
CONSUMER_ARN_FIELD, CONSUMER_STATUS_FIELD, CONSUMER_CREATION_TIMESTAMP_FIELD, STREAM_ARN_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("ConsumerName", CONSUMER_NAME_FIELD);
put("ConsumerARN", CONSUMER_ARN_FIELD);
put("ConsumerStatus", CONSUMER_STATUS_FIELD);
put("ConsumerCreationTimestamp", CONSUMER_CREATION_TIMESTAMP_FIELD);
put("StreamARN", STREAM_ARN_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String consumerName;
private final String consumerARN;
private final String consumerStatus;
private final Instant consumerCreationTimestamp;
private final String streamARN;
private ConsumerDescription(BuilderImpl builder) {
this.consumerName = builder.consumerName;
this.consumerARN = builder.consumerARN;
this.consumerStatus = builder.consumerStatus;
this.consumerCreationTimestamp = builder.consumerCreationTimestamp;
this.streamARN = builder.streamARN;
}
/**
*
* The name of the consumer is something you choose when you register the consumer.
*
*
* @return The name of the consumer is something you choose when you register the consumer.
*/
public final String consumerName() {
return consumerName;
}
/**
*
* When you register a consumer, Kinesis Data Streams generates an ARN for it. You need this ARN to be able to call
* SubscribeToShard.
*
*
* If you delete a consumer and then create a new one with the same name, it won't have the same ARN. That's because
* consumer ARNs contain the creation timestamp. This is important to keep in mind if you have IAM policies that
* reference consumer ARNs.
*
*
* @return When you register a consumer, Kinesis Data Streams generates an ARN for it. You need this ARN to be able
* to call SubscribeToShard.
*
* If you delete a consumer and then create a new one with the same name, it won't have the same ARN. That's
* because consumer ARNs contain the creation timestamp. This is important to keep in mind if you have IAM
* policies that reference consumer ARNs.
*/
public final String consumerARN() {
return consumerARN;
}
/**
*
* A consumer can't read data while in the CREATING
or DELETING
states.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #consumerStatus}
* will return {@link ConsumerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #consumerStatusAsString}.
*
*
* @return A consumer can't read data while in the CREATING
or DELETING
states.
* @see ConsumerStatus
*/
public final ConsumerStatus consumerStatus() {
return ConsumerStatus.fromValue(consumerStatus);
}
/**
*
* A consumer can't read data while in the CREATING
or DELETING
states.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #consumerStatus}
* will return {@link ConsumerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #consumerStatusAsString}.
*
*
* @return A consumer can't read data while in the CREATING
or DELETING
states.
* @see ConsumerStatus
*/
public final String consumerStatusAsString() {
return consumerStatus;
}
/**
*
*
* @return
*/
public final Instant consumerCreationTimestamp() {
return consumerCreationTimestamp;
}
/**
*
* The ARN of the stream with which you registered the consumer.
*
*
* @return The ARN of the stream with which you registered the consumer.
*/
public final String streamARN() {
return streamARN;
}
@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(consumerName());
hashCode = 31 * hashCode + Objects.hashCode(consumerARN());
hashCode = 31 * hashCode + Objects.hashCode(consumerStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(consumerCreationTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(streamARN());
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 ConsumerDescription)) {
return false;
}
ConsumerDescription other = (ConsumerDescription) obj;
return Objects.equals(consumerName(), other.consumerName()) && Objects.equals(consumerARN(), other.consumerARN())
&& Objects.equals(consumerStatusAsString(), other.consumerStatusAsString())
&& Objects.equals(consumerCreationTimestamp(), other.consumerCreationTimestamp())
&& Objects.equals(streamARN(), other.streamARN());
}
/**
* 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("ConsumerDescription").add("ConsumerName", consumerName()).add("ConsumerARN", consumerARN())
.add("ConsumerStatus", consumerStatusAsString()).add("ConsumerCreationTimestamp", consumerCreationTimestamp())
.add("StreamARN", streamARN()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ConsumerName":
return Optional.ofNullable(clazz.cast(consumerName()));
case "ConsumerARN":
return Optional.ofNullable(clazz.cast(consumerARN()));
case "ConsumerStatus":
return Optional.ofNullable(clazz.cast(consumerStatusAsString()));
case "ConsumerCreationTimestamp":
return Optional.ofNullable(clazz.cast(consumerCreationTimestamp()));
case "StreamARN":
return Optional.ofNullable(clazz.cast(streamARN()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function