hachikuji commented on a change in pull request #10892: URL: https://github.com/apache/kafka/pull/10892#discussion_r656431145
########## File path: clients/src/main/java/org/apache/kafka/clients/admin/TopicCollection.java ########## @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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 org.apache.kafka.clients.admin; + +import org.apache.kafka.common.Uuid; + +import java.util.Collection; + +public class TopicCollection { Review comment: Did you make this name generic so that it could handle other use cases? ########## File path: clients/src/main/java/org/apache/kafka/clients/admin/TopicCollection.java ########## @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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 org.apache.kafka.clients.admin; + +import org.apache.kafka.common.Uuid; + +import java.util.Collection; + +public class TopicCollection { + + private Collection<String> topicNames; + private Collection<Uuid> topicIds; + private final TopicAttribute attribute; + + public enum TopicAttribute { + TOPIC_NAME, TOPIC_ID Review comment: Another way to do this might be to make `TopicCollect` abstract and create two implementations: ```java abstract class TopicCollection class TopicIdCollection extends TopicCollection class TopicNameCollection extends TopicCollection public static TopicIdCollection ofTopicIds(Collection<Uuid> topicIds); public static TopicNameCollection ofTopicNames(Collection<String> topicNames); ``` ########## File path: clients/src/main/java/org/apache/kafka/clients/admin/Admin.java ########## @@ -233,41 +232,41 @@ default DeleteTopicsResult deleteTopics(Collection<String> topics) { * @return The DeleteTopicsResult. */ DeleteTopicsResult deleteTopics(Collection<String> topics, DeleteTopicsOptions options); - + /** - * This is a convenience method for {@link #deleteTopicsWithIds(Collection, DeleteTopicsOptions)} + * This is a convenience method for {@link #deleteTopics(TopicCollection, DeleteTopicsOptions)} * with default options. See the overload for more details. * <p> - * This operation is supported by brokers with version 2.8.0 or higher. + * This operation is supported by brokers with version 3.0.0 or higher. * - * @param topics The topic IDs for the topics to delete. - * @return The DeleteTopicsWithIdsResult. + * @param topics The topics to delete. + * @return The DeleteTopicsResult. */ - default DeleteTopicsWithIdsResult deleteTopicsWithIds(Collection<Uuid> topics) { - return deleteTopicsWithIds(topics, new DeleteTopicsOptions()); + default DeleteTopicsResult deleteTopics(TopicCollection topics) { + return deleteTopics(topics, new DeleteTopicsOptions()); } /** * Delete a batch of topics. * <p> * This operation is not transactional so it may succeed for some topics while fail for others. * <p> - * It may take several seconds after the {@link DeleteTopicsWithIdsResult} returns + * It may take several seconds after the {@link DeleteTopicsResult} returns * success for all the brokers to become aware that the topics are gone. * During this time, {@link #listTopics()} and {@link #describeTopics(Collection)} * may continue to return information about the deleted topics. * <p> - * If delete.topic.enable is false on the brokers, deleteTopicsWithIds will mark + * If delete.topic.enable is false on the brokers, deleteTopics will mark * the topics for deletion, but not actually delete them. The futures will * return successfully in this case. * <p> - * This operation is supported by brokers with version 2.8.0 or higher. + * This operation is supported by brokers with version 3.0.0 or higher. * - * @param topics The topic IDs for the topics to delete. + * @param topics The topics to delete. * @param options The options to use when deleting the topics. - * @return The DeleteTopicsWithIdsResult. + * @return The DeleteTopicsResult. */ - DeleteTopicsWithIdsResult deleteTopicsWithIds(Collection<Uuid> topics, DeleteTopicsOptions options); + DeleteTopicsResult deleteTopics(TopicCollection topics, DeleteTopicsOptions options); Review comment: Since `TopicCollection` can handle both "by name" and "by ID" deletion, is the intent to eventually deprecate the old deletion api or will we keep it around for convenience? ########## File path: clients/src/main/java/org/apache/kafka/clients/admin/Admin.java ########## @@ -233,41 +232,41 @@ default DeleteTopicsResult deleteTopics(Collection<String> topics) { * @return The DeleteTopicsResult. */ DeleteTopicsResult deleteTopics(Collection<String> topics, DeleteTopicsOptions options); - + Review comment: Would it make sense to provide a default implementation to translate to `TopicCollection`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org