From d9390fd68fceaf1d86ba907104c0b98fdac98a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roope=20Karhap=C3=A4=C3=A4?= Date: Thu, 5 Sep 2024 09:04:16 +0300 Subject: [PATCH] feat: Add support for description and owner for topics makes it possible to provide topic_description and owner_user_group_id when creating and updating topic. Also adds it to the schema. --- kafka_topic.go | 8 ++++++++ kafka_topic_acc_test.go | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/kafka_topic.go b/kafka_topic.go index 980a3dc..1b9b73a 100644 --- a/kafka_topic.go +++ b/kafka_topic.go @@ -122,6 +122,8 @@ type ( TopicName string `json:"topic_name"` Config KafkaTopicConfigResponse `json:"config"` Tags []KafkaTopicTag `json:"tags,omitempty"` + TopicDescription string `json:"topic_description"` + OwnerUserGroupId string `json:"owner_user_group_id"` } // KafkaListTopic represents kafka list topic model on Aiven. @@ -134,6 +136,8 @@ type ( RetentionHours *int64 `json:"retention_hours,omitempty"` State string `json:"state"` TopicName string `json:"topic_name"` + TopicDescription string `json:"topic_description"` + OwnerUserGroupId string `json:"owner_user_group_id"` } // Partition represents a Kafka partition. @@ -169,6 +173,8 @@ type ( TopicName string `json:"topic_name"` Config KafkaTopicConfig `json:"config"` Tags []KafkaTopicTag `json:"tags,omitempty"` + TopicDescription string `json:"topic_description,omitempty"` + OwnerUserGroupId string `json:"owner_user_group_id,omitempty"` } // UpdateKafkaTopicRequest are the parameters used to update a kafka topic. @@ -180,6 +186,8 @@ type ( RetentionHours *int `json:"retention_hours,omitempty"` Config KafkaTopicConfig `json:"config"` Tags []KafkaTopicTag `json:"tags,omitempty"` + TopicDescription string `json:"topic_description,omitempty"` + OwnerUserGroupId string `json:"owner_user_group_id,omitempty"` } // KafkaTopicResponse is the response for Kafka Topic requests. diff --git a/kafka_topic_acc_test.go b/kafka_topic_acc_test.go index a8ad56e..d8dc85a 100644 --- a/kafka_topic_acc_test.go +++ b/kafka_topic_acc_test.go @@ -75,12 +75,16 @@ var _ = Describe("Kafka Topic", func() { // kafka topic var ( - errC error - topicName string - segmentJitterMs int64 + errC error + topicName string + segmentJitterMs int64 + topicDescription string + ownerUserGroupId string ) segmentJitterMs = 10 topicName = "test1" + topicDescription = "test-description" + ownerUserGroupId = "org22ba494e096" It("create kafka topic", func() { time.Sleep(10 * time.Second) @@ -96,6 +100,8 @@ var _ = Describe("Kafka Topic", func() { Value: "tag1-value", }, }, + TopicDescription: topicDescription, + OwnerUserGroupId: ownerUserGroupId, }) Eventually(func() string { @@ -123,13 +129,18 @@ var _ = Describe("Kafka Topic", func() { Expect(t.Tags).NotTo(BeEmpty()) Expect(t.Tags[0].Key).To(Equal("tag1-key")) Expect(t.Tags[0].Value).To(Equal("tag1-value")) + Expect(t.TopicDescription).To(Equal(topicDescription)) + Expect(t.OwnerUserGroupId).To(Equal(ownerUserGroupId)) } }) It("should update topic config", func() { var uncleanLeaderElectionEnable = true + var newTopicDescription = "test-description-2" + var newOwnerUserGroupId = "org22ba494e097" errU := client.KafkaTopics.Update(ctx, projectName, serviceName, topicName, UpdateKafkaTopicRequest{ + TopicDescription: newTopicDescription, Config: KafkaTopicConfig{ UncleanLeaderElectionEnable: &uncleanLeaderElectionEnable, }, @@ -154,6 +165,8 @@ var _ = Describe("Kafka Topic", func() { Expect(t2.Config.UncleanLeaderElectionEnable.Value).Should(Equal(true)) Expect(t2.Tags).ShouldNot(BeEmpty()) Expect(len(t2.Tags)).To(Equal(2)) + Expect(t2.TopicDescription).To(Equal(newTopicDescription)) + Expect(t2.OwnerUserGroupId).To(Equal(newOwnerUserGroupId)) } }) @@ -166,6 +179,9 @@ var _ = Describe("Kafka Topic", func() { Expect(list[0].Config.SegmentJitterMs.Value).To(Equal(segmentJitterMs)) Expect(list[0].Tags).NotTo(BeEmpty()) Expect(len(list[0].Tags)).To(Equal(2)) + Expect(list[0].TopicDescription).To(Equal(topicDescription)) + Expect(list[0].OwnerUserGroupId).To(Equal(ownerUserGroupId)) + }) It("delete Kafka Topic and Kafka service", func() {