Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.kinesis.model.CreateStreamRequest Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Amazon Kinesis module holds the client classes that are used for communicating
with Amazon Kinesis Service
/*
* 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.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.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the input for CreateStream
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateStreamRequest extends KinesisRequest implements
ToCopyableBuilder {
private static final SdkField STREAM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StreamName").getter(getter(CreateStreamRequest::streamName)).setter(setter(Builder::streamName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StreamName").build()).build();
private static final SdkField SHARD_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ShardCount").getter(getter(CreateStreamRequest::shardCount)).setter(setter(Builder::shardCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShardCount").build()).build();
private static final SdkField STREAM_MODE_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("StreamModeDetails")
.getter(getter(CreateStreamRequest::streamModeDetails)).setter(setter(Builder::streamModeDetails))
.constructor(StreamModeDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StreamModeDetails").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("Tags")
.getter(getter(CreateStreamRequest::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STREAM_NAME_FIELD,
SHARD_COUNT_FIELD, STREAM_MODE_DETAILS_FIELD, TAGS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("StreamName", STREAM_NAME_FIELD);
put("ShardCount", SHARD_COUNT_FIELD);
put("StreamModeDetails", STREAM_MODE_DETAILS_FIELD);
put("Tags", TAGS_FIELD);
}
});
private final String streamName;
private final Integer shardCount;
private final StreamModeDetails streamModeDetails;
private final Map tags;
private CreateStreamRequest(BuilderImpl builder) {
super(builder);
this.streamName = builder.streamName;
this.shardCount = builder.shardCount;
this.streamModeDetails = builder.streamModeDetails;
this.tags = builder.tags;
}
/**
*
* A name to identify the stream. The stream name is scoped to the Amazon Web Services account used by the
* application that creates the stream. It is also scoped by Amazon Web Services Region. That is, two streams in two
* different Amazon Web Services accounts can have the same name. Two streams in the same Amazon Web Services
* account but in two different Regions can also have the same name.
*
*
* @return A name to identify the stream. The stream name is scoped to the Amazon Web Services account used by the
* application that creates the stream. It is also scoped by Amazon Web Services Region. That is, two
* streams in two different Amazon Web Services accounts can have the same name. Two streams in the same
* Amazon Web Services account but in two different Regions can also have the same name.
*/
public final String streamName() {
return streamName;
}
/**
*
* The number of shards that the stream will use. The throughput of the stream is a function of the number of
* shards; more shards are required for greater provisioned throughput.
*
*
* @return The number of shards that the stream will use. The throughput of the stream is a function of the number
* of shards; more shards are required for greater provisioned throughput.
*/
public final Integer shardCount() {
return shardCount;
}
/**
*
* Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose between an
* on-demand capacity mode and a provisioned capacity mode for your data streams.
*
*
* @return Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose
* between an on-demand capacity mode and a provisioned capacity mode for your data streams.
*/
public final StreamModeDetails streamModeDetails() {
return streamModeDetails;
}
/**
* 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 SdkAutoConstructMap);
}
/**
*
* A set of up to 10 key-value pairs to use to create the tags.
*
*
* 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 A set of up to 10 key-value pairs to use to create the tags.
*/
public final Map tags() {
return tags;
}
@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(streamName());
hashCode = 31 * hashCode + Objects.hashCode(shardCount());
hashCode = 31 * hashCode + Objects.hashCode(streamModeDetails());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 CreateStreamRequest)) {
return false;
}
CreateStreamRequest other = (CreateStreamRequest) obj;
return Objects.equals(streamName(), other.streamName()) && Objects.equals(shardCount(), other.shardCount())
&& Objects.equals(streamModeDetails(), other.streamModeDetails()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags());
}
/**
* 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("CreateStreamRequest").add("StreamName", streamName()).add("ShardCount", shardCount())
.add("StreamModeDetails", streamModeDetails()).add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StreamName":
return Optional.ofNullable(clazz.cast(streamName()));
case "ShardCount":
return Optional.ofNullable(clazz.cast(shardCount()));
case "StreamModeDetails":
return Optional.ofNullable(clazz.cast(streamModeDetails()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
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 getter(Function g) {
return obj -> g.apply((CreateStreamRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends KinesisRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* A name to identify the stream. The stream name is scoped to the Amazon Web Services account used by the
* application that creates the stream. It is also scoped by Amazon Web Services Region. That is, two streams in
* two different Amazon Web Services accounts can have the same name. Two streams in the same Amazon Web
* Services account but in two different Regions can also have the same name.
*
*
* @param streamName
* A name to identify the stream. The stream name is scoped to the Amazon Web Services account used by
* the application that creates the stream. It is also scoped by Amazon Web Services Region. That is, two
* streams in two different Amazon Web Services accounts can have the same name. Two streams in the same
* Amazon Web Services account but in two different Regions can also have the same name.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder streamName(String streamName);
/**
*
* The number of shards that the stream will use. The throughput of the stream is a function of the number of
* shards; more shards are required for greater provisioned throughput.
*
*
* @param shardCount
* The number of shards that the stream will use. The throughput of the stream is a function of the
* number of shards; more shards are required for greater provisioned throughput.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder shardCount(Integer shardCount);
/**
*
* Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose between an
* on-demand capacity mode and a provisioned capacity mode for your data streams.
*
*
* @param streamModeDetails
* Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose
* between an on-demand capacity mode and a provisioned capacity mode for your data
* streams.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder streamModeDetails(StreamModeDetails streamModeDetails);
/**
*
* Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose between an
* on-demand capacity mode and a provisioned capacity mode for your data streams.
*
* This is a convenience method that creates an instance of the {@link StreamModeDetails.Builder} avoiding the
* need to create one manually via {@link StreamModeDetails#builder()}.
*
*
* When the {@link Consumer} completes, {@link StreamModeDetails.Builder#build()} is called immediately and its
* result is passed to {@link #streamModeDetails(StreamModeDetails)}.
*
* @param streamModeDetails
* a consumer that will call methods on {@link StreamModeDetails.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #streamModeDetails(StreamModeDetails)
*/
default Builder streamModeDetails(Consumer streamModeDetails) {
return streamModeDetails(StreamModeDetails.builder().applyMutation(streamModeDetails).build());
}
/**
*
* A set of up to 10 key-value pairs to use to create the tags.
*
*
* @param tags
* A set of up to 10 key-value pairs to use to create the tags.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tags(Map tags);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends KinesisRequest.BuilderImpl implements Builder {
private String streamName;
private Integer shardCount;
private StreamModeDetails streamModeDetails;
private Map tags = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(CreateStreamRequest model) {
super(model);
streamName(model.streamName);
shardCount(model.shardCount);
streamModeDetails(model.streamModeDetails);
tags(model.tags);
}
public final String getStreamName() {
return streamName;
}
public final void setStreamName(String streamName) {
this.streamName = streamName;
}
@Override
public final Builder streamName(String streamName) {
this.streamName = streamName;
return this;
}
public final Integer getShardCount() {
return shardCount;
}
public final void setShardCount(Integer shardCount) {
this.shardCount = shardCount;
}
@Override
public final Builder shardCount(Integer shardCount) {
this.shardCount = shardCount;
return this;
}
public final StreamModeDetails.Builder getStreamModeDetails() {
return streamModeDetails != null ? streamModeDetails.toBuilder() : null;
}
public final void setStreamModeDetails(StreamModeDetails.BuilderImpl streamModeDetails) {
this.streamModeDetails = streamModeDetails != null ? streamModeDetails.build() : null;
}
@Override
public final Builder streamModeDetails(StreamModeDetails streamModeDetails) {
this.streamModeDetails = streamModeDetails;
return this;
}
public final Map getTags() {
if (tags instanceof SdkAutoConstructMap) {
return null;
}
return tags;
}
public final void setTags(Map tags) {
this.tags = TagMapCopier.copy(tags);
}
@Override
public final Builder tags(Map tags) {
this.tags = TagMapCopier.copy(tags);
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public CreateStreamRequest build() {
return new CreateStreamRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}