software.amazon.awssdk.services.kafka.model.TopicReplication Maven / Gradle / Ivy
Show all versions of kafka 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.kafka.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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.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;
/**
*
* Details about topic replication.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TopicReplication implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField COPY_ACCESS_CONTROL_LISTS_FOR_TOPICS_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("CopyAccessControlListsForTopics")
.getter(getter(TopicReplication::copyAccessControlListsForTopics))
.setter(setter(Builder::copyAccessControlListsForTopics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("copyAccessControlListsForTopics")
.build()).build();
private static final SdkField COPY_TOPIC_CONFIGURATIONS_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("CopyTopicConfigurations").getter(getter(TopicReplication::copyTopicConfigurations))
.setter(setter(Builder::copyTopicConfigurations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("copyTopicConfigurations").build())
.build();
private static final SdkField DETECT_AND_COPY_NEW_TOPICS_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("DetectAndCopyNewTopics").getter(getter(TopicReplication::detectAndCopyNewTopics))
.setter(setter(Builder::detectAndCopyNewTopics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("detectAndCopyNewTopics").build())
.build();
private static final SdkField STARTING_POSITION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("StartingPosition")
.getter(getter(TopicReplication::startingPosition)).setter(setter(Builder::startingPosition))
.constructor(ReplicationStartingPosition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startingPosition").build()).build();
private static final SdkField TOPIC_NAME_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TopicNameConfiguration")
.getter(getter(TopicReplication::topicNameConfiguration)).setter(setter(Builder::topicNameConfiguration))
.constructor(ReplicationTopicNameConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("topicNameConfiguration").build())
.build();
private static final SdkField> TOPICS_TO_EXCLUDE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TopicsToExclude")
.getter(getter(TopicReplication::topicsToExclude))
.setter(setter(Builder::topicsToExclude))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("topicsToExclude").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> TOPICS_TO_REPLICATE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TopicsToReplicate")
.getter(getter(TopicReplication::topicsToReplicate))
.setter(setter(Builder::topicsToReplicate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("topicsToReplicate").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
COPY_ACCESS_CONTROL_LISTS_FOR_TOPICS_FIELD, COPY_TOPIC_CONFIGURATIONS_FIELD, DETECT_AND_COPY_NEW_TOPICS_FIELD,
STARTING_POSITION_FIELD, TOPIC_NAME_CONFIGURATION_FIELD, TOPICS_TO_EXCLUDE_FIELD, TOPICS_TO_REPLICATE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("copyAccessControlListsForTopics", COPY_ACCESS_CONTROL_LISTS_FOR_TOPICS_FIELD);
put("copyTopicConfigurations", COPY_TOPIC_CONFIGURATIONS_FIELD);
put("detectAndCopyNewTopics", DETECT_AND_COPY_NEW_TOPICS_FIELD);
put("startingPosition", STARTING_POSITION_FIELD);
put("topicNameConfiguration", TOPIC_NAME_CONFIGURATION_FIELD);
put("topicsToExclude", TOPICS_TO_EXCLUDE_FIELD);
put("topicsToReplicate", TOPICS_TO_REPLICATE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Boolean copyAccessControlListsForTopics;
private final Boolean copyTopicConfigurations;
private final Boolean detectAndCopyNewTopics;
private final ReplicationStartingPosition startingPosition;
private final ReplicationTopicNameConfiguration topicNameConfiguration;
private final List topicsToExclude;
private final List topicsToReplicate;
private TopicReplication(BuilderImpl builder) {
this.copyAccessControlListsForTopics = builder.copyAccessControlListsForTopics;
this.copyTopicConfigurations = builder.copyTopicConfigurations;
this.detectAndCopyNewTopics = builder.detectAndCopyNewTopics;
this.startingPosition = builder.startingPosition;
this.topicNameConfiguration = builder.topicNameConfiguration;
this.topicsToExclude = builder.topicsToExclude;
this.topicsToReplicate = builder.topicsToReplicate;
}
/**
*
* Whether to periodically configure remote topic ACLs to match their corresponding upstream topics.
*
*
* @return Whether to periodically configure remote topic ACLs to match their corresponding upstream topics.
*/
public final Boolean copyAccessControlListsForTopics() {
return copyAccessControlListsForTopics;
}
/**
*
* Whether to periodically configure remote topics to match their corresponding upstream topics.
*
*
* @return Whether to periodically configure remote topics to match their corresponding upstream topics.
*/
public final Boolean copyTopicConfigurations() {
return copyTopicConfigurations;
}
/**
*
* Whether to periodically check for new topics and partitions.
*
*
* @return Whether to periodically check for new topics and partitions.
*/
public final Boolean detectAndCopyNewTopics() {
return detectAndCopyNewTopics;
}
/**
*
* Configuration for specifying the position in the topics to start replicating from.
*
*
* @return Configuration for specifying the position in the topics to start replicating from.
*/
public final ReplicationStartingPosition startingPosition() {
return startingPosition;
}
/**
*
* Configuration for specifying replicated topic names should be the same as their corresponding upstream topics or
* prefixed with source cluster alias.
*
*
* @return Configuration for specifying replicated topic names should be the same as their corresponding upstream
* topics or prefixed with source cluster alias.
*/
public final ReplicationTopicNameConfiguration topicNameConfiguration() {
return topicNameConfiguration;
}
/**
* For responses, this returns true if the service returned a value for the TopicsToExclude 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 hasTopicsToExclude() {
return topicsToExclude != null && !(topicsToExclude instanceof SdkAutoConstructList);
}
/**
*
* List of regular expression patterns indicating the topics that should not be replicated.
*
*
* 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 #hasTopicsToExclude} method.
*
*
* @return List of regular expression patterns indicating the topics that should not be replicated.
*/
public final List topicsToExclude() {
return topicsToExclude;
}
/**
* For responses, this returns true if the service returned a value for the TopicsToReplicate 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 hasTopicsToReplicate() {
return topicsToReplicate != null && !(topicsToReplicate instanceof SdkAutoConstructList);
}
/**
*
* List of regular expression patterns indicating the topics to copy.
*
*
* 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 #hasTopicsToReplicate} method.
*
*
* @return List of regular expression patterns indicating the topics to copy.
*/
public final List topicsToReplicate() {
return topicsToReplicate;
}
@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(copyAccessControlListsForTopics());
hashCode = 31 * hashCode + Objects.hashCode(copyTopicConfigurations());
hashCode = 31 * hashCode + Objects.hashCode(detectAndCopyNewTopics());
hashCode = 31 * hashCode + Objects.hashCode(startingPosition());
hashCode = 31 * hashCode + Objects.hashCode(topicNameConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(hasTopicsToExclude() ? topicsToExclude() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTopicsToReplicate() ? topicsToReplicate() : null);
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 TopicReplication)) {
return false;
}
TopicReplication other = (TopicReplication) obj;
return Objects.equals(copyAccessControlListsForTopics(), other.copyAccessControlListsForTopics())
&& Objects.equals(copyTopicConfigurations(), other.copyTopicConfigurations())
&& Objects.equals(detectAndCopyNewTopics(), other.detectAndCopyNewTopics())
&& Objects.equals(startingPosition(), other.startingPosition())
&& Objects.equals(topicNameConfiguration(), other.topicNameConfiguration())
&& hasTopicsToExclude() == other.hasTopicsToExclude()
&& Objects.equals(topicsToExclude(), other.topicsToExclude())
&& hasTopicsToReplicate() == other.hasTopicsToReplicate()
&& Objects.equals(topicsToReplicate(), other.topicsToReplicate());
}
/**
* 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("TopicReplication").add("CopyAccessControlListsForTopics", copyAccessControlListsForTopics())
.add("CopyTopicConfigurations", copyTopicConfigurations())
.add("DetectAndCopyNewTopics", detectAndCopyNewTopics()).add("StartingPosition", startingPosition())
.add("TopicNameConfiguration", topicNameConfiguration())
.add("TopicsToExclude", hasTopicsToExclude() ? topicsToExclude() : null)
.add("TopicsToReplicate", hasTopicsToReplicate() ? topicsToReplicate() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CopyAccessControlListsForTopics":
return Optional.ofNullable(clazz.cast(copyAccessControlListsForTopics()));
case "CopyTopicConfigurations":
return Optional.ofNullable(clazz.cast(copyTopicConfigurations()));
case "DetectAndCopyNewTopics":
return Optional.ofNullable(clazz.cast(detectAndCopyNewTopics()));
case "StartingPosition":
return Optional.ofNullable(clazz.cast(startingPosition()));
case "TopicNameConfiguration":
return Optional.ofNullable(clazz.cast(topicNameConfiguration()));
case "TopicsToExclude":
return Optional.ofNullable(clazz.cast(topicsToExclude()));
case "TopicsToReplicate":
return Optional.ofNullable(clazz.cast(topicsToReplicate()));
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