From 94ca4a06de7bae08d656e49a6fa11b9b28d4ce99 Mon Sep 17 00:00:00 2001
From: Zippo-Wang <852420284@qq.com>
Date: Fri, 28 Nov 2025 16:53:59 +0800
Subject: [PATCH] feat(eg): add new fields of EG data source and resource
---
docs/data-sources/eg_connections.md | 4 +-
docs/data-sources/eg_custom_event_channels.md | 4 +
docs/data-sources/eg_custom_event_sources.md | 20 ++-
docs/resources/eg_connection.md | 20 +++
..._source_huaweicloud_eg_connections_test.go | 1 +
...aweicloud_eg_custom_event_channels_test.go | 104 +++++++++++++++
...uaweicloud_eg_custom_event_sources_test.go | 126 ++++++++++++++++++
...resource_huaweicloud_eg_connection_test.go | 6 +
.../data_source_huaweicloud_eg_connections.go | 6 +
...ce_huaweicloud_eg_custom_event_channels.go | 16 +++
...rce_huaweicloud_eg_custom_event_sources.go | 48 +++++++
.../eg/resource_huaweicloud_eg_connection.go | 94 +++++++++++--
12 files changed, 435 insertions(+), 14 deletions(-)
diff --git a/docs/data-sources/eg_connections.md b/docs/data-sources/eg_connections.md
index ef5c65e870f..f21b0ab183c 100644
--- a/docs/data-sources/eg_connections.md
+++ b/docs/data-sources/eg_connections.md
@@ -98,7 +98,9 @@ The `kafka_detail` block supports:
* `user_name` - The username of the Kafka instance.
-* `acks` - The number of confirmation signals the producer‌ needs to receive to consider the message sent successfully.
+* `acks` - The number of confirmation signals the producer needs to receive to consider the message sent successfully.
+
+* `address` - The connection address of Kafka instance.
The `flavor` block supports:
diff --git a/docs/data-sources/eg_custom_event_channels.md b/docs/data-sources/eg_custom_event_channels.md
index 6a35cdf33c8..b0938606819 100644
--- a/docs/data-sources/eg_custom_event_channels.md
+++ b/docs/data-sources/eg_custom_event_channels.md
@@ -28,6 +28,10 @@ The following arguments are supported:
* `name` - (Optional, String) Specifies the channel name used to query specified custom event channel.
+* `fuzzy_name` - (Optional, String) Specifies the name of the channels to be queried for fuzzy matching.
+
+* `sort` - (Optional, String) Specifies the sorting method for query results.
+
* `enterprise_project_id` - (Optional, String) Specifies the ID of the enterprise project to which the custom event
channels belong.
diff --git a/docs/data-sources/eg_custom_event_sources.md b/docs/data-sources/eg_custom_event_sources.md
index fcaa383806a..322dda17960 100644
--- a/docs/data-sources/eg_custom_event_sources.md
+++ b/docs/data-sources/eg_custom_event_sources.md
@@ -33,6 +33,10 @@ The following arguments are supported:
* `name` - (Optional, String) Specifies the event source name used to query specified custom event source.
+* `fuzzy_name` - (Optional, String) Specifies the name of the channels to be queried for fuzzy matching.
+
+* `sort` - (Optional, String) Specifies the sorting method for query results.
+
## Attribute Reference
In addition to all arguments above, the following attributes are exported:
@@ -40,7 +44,7 @@ In addition to all arguments above, the following attributes are exported:
* `id` - The data source ID.
* `sources` - The filtered custom event source.
- The [object](#eg_custom_event_sources) structure is documented below.
+ The [sources](#eg_custom_event_sources) structure is documented below.
The `sources` block supports:
@@ -62,6 +66,20 @@ The `sources` block supports:
+ **RUNNING**
+ **ERROR**
+* `detail` - The message instance link information, in JSON format.
+
+* `error_info` - The error information of the custom event source.
+ The [error_info](#data_custom_event_sources_error_info) structure is documented below.
+
* `created_at` - The creation time of the custom event source.
* `updated_at` - The update time of the custom event source.
+
+
+The `error_info` block supports:
+
+* `error_code` - The error code of current source.
+
+* `error_detail` - The error detail of current source.
+
+* `error_msg` - The error message of current source.
diff --git a/docs/resources/eg_connection.md b/docs/resources/eg_connection.md
index c26901e4cff..26ec934966c 100644
--- a/docs/resources/eg_connection.md
+++ b/docs/resources/eg_connection.md
@@ -120,6 +120,10 @@ The `KafkaDetail` block supports:
Changing this parameter will create a new resource.
+* `security_protocol` - (Optional, String, ForceNew) Specifies the security protocol of the kafka instance.
+
+ Changing this parameter will create a new resource.
+
## Attribute Reference
In addition to all arguments above, the following attributes are exported:
@@ -128,10 +132,26 @@ In addition to all arguments above, the following attributes are exported:
* `status` - Indicates the status of the connection.
+* `agency` - Indicates the user-delegated name used for private network target connection.
+
* `created_at` - The creation time of the connection.
* `updated_at` - The last update time of the connection.
+* `flavor` - The configuration details of the kafka instance.
+ The [flavor](#connection_flavor) structure is documented below.
+
+
+The `flavor` block supports:
+
+* `name` - The name of the kafka instance.
+
+* `bandwidth_type` - The bandwidth type of the kafka instance.
+
+* `concurrency` - The concurrency number of the kafka instance.
+
+* `concurrency_type` - The concurrency type of the kafka instance.
+
## Import
The connection can be imported using the `id`, e.g.
diff --git a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_connections_test.go b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_connections_test.go
index 803f83d037d..14e2bb8a75e 100644
--- a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_connections_test.go
+++ b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_connections_test.go
@@ -135,6 +135,7 @@ output "is_kafka_detail_and_valid" {
lookup(local.kafka_connection_filter_result, "enable_sasl_ssl", "") == true,
lookup(local.kafka_connection_filter_result, "user_name", "") != "",
lookup(local.kafka_connection_filter_result, "acks", "") != "",
+ lookup(local.kafka_connection_filter_result, "address", "") != "",
])
}
`, acceptance.HW_EG_CONNECTION_IDS)
diff --git a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_channels_test.go b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_channels_test.go
index 6a331870f8e..25d62b46403 100644
--- a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_channels_test.go
+++ b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_channels_test.go
@@ -237,3 +237,107 @@ output "eps_id_not_found_validation_pass" {
}
`, testAccDataCustomEventChannels_base_withEpsId(), acceptance.HW_ENTERPRISE_PROJECT_ID_TEST, randUUID)
}
+
+func TestAccDataCustomEventChannels_fuzzyName(t *testing.T) {
+ var (
+ baseRes = "huaweicloud_eg_custom_event_channel.test"
+ byFuzzy = "data.huaweicloud_eg_custom_event_channels.filter_by_fuzzy_name"
+
+ obj interface{}
+ rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventChannelFunc)
+ dcFuzzy = acceptance.InitDataSourceCheck(byFuzzy)
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { acceptance.TestAccPreCheck(t) },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccDataCustomEventChannels_fuzzyName(),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ dcFuzzy.CheckResourceExists(),
+ resource.TestCheckOutput("is_fuzzy_name_filter_useful", "true"),
+ ),
+ },
+ },
+ })
+}
+
+func testAccDataCustomEventChannels_fuzzyName() string {
+ name := acceptance.RandomAccResourceName()
+ fuzzyName := name[:len(name)-3]
+
+ return fmt.Sprintf(`
+resource "huaweicloud_eg_custom_event_channel" "test" {
+ name = "%[1]s"
+}
+
+data "huaweicloud_eg_custom_event_channels" "filter_by_fuzzy_name" {
+ depends_on = [
+ huaweicloud_eg_custom_event_channel.test,
+ ]
+
+ fuzzy_name = "%[2]s"
+}
+
+locals {
+ filter_result = [for v in data.huaweicloud_eg_custom_event_channels.filter_by_fuzzy_name.channels[*].name :
+ can(regex(".*%[2]s.*", v))]
+}
+
+output "is_fuzzy_name_filter_useful" {
+ value = alltrue(local.filter_result) && length(local.filter_result) > 0
+}
+`, name, fuzzyName)
+}
+
+func TestAccDataCustomEventChannels_sort(t *testing.T) {
+ var (
+ baseRes = "huaweicloud_eg_custom_event_channel.test"
+ bySort = "data.huaweicloud_eg_custom_event_channels.sort_by_name"
+
+ obj interface{}
+ rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventChannelFunc)
+ dcSort = acceptance.InitDataSourceCheck(bySort)
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { acceptance.TestAccPreCheck(t) },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccDataCustomEventChannels_sort(),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ dcSort.CheckResourceExists(),
+ resource.TestCheckOutput("is_sort_useful", "true"),
+ ),
+ },
+ },
+ })
+}
+
+func testAccDataCustomEventChannels_sort() string {
+ name := acceptance.RandomAccResourceName()
+
+ return fmt.Sprintf(`
+resource "huaweicloud_eg_custom_event_channel" "test" {
+ name = "%[1]s"
+}
+
+data "huaweicloud_eg_custom_event_channels" "sort_by_name" {
+ depends_on = [
+ huaweicloud_eg_custom_event_channel.test,
+ ]
+
+ sort = "created_time:DESC"
+}
+
+output "is_sort_useful" {
+ value = length(data.huaweicloud_eg_custom_event_channels.sort_by_name.channels) > 0
+}
+`, name)
+}
diff --git a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_sources_test.go b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_sources_test.go
index 6f67749047f..820ea673087 100644
--- a/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_sources_test.go
+++ b/huaweicloud/services/acceptance/eg/data_source_huaweicloud_eg_custom_event_sources_test.go
@@ -236,3 +236,129 @@ output "channel_id_not_found_validation_pass" {
}
`, testAccDataCustomEventSources_base(), acceptance.HW_EG_CHANNEL_ID, randUUID)
}
+
+func TestAccDataCustomEventSources_filterByFuzzyName(t *testing.T) {
+ var (
+ baseRes = "huaweicloud_eg_custom_event_source.test"
+ byFuzzyName = "data.huaweicloud_eg_custom_event_sources.filter_by_fuzzy_name"
+ fuzzyNameNotFound = "data.huaweicloud_eg_custom_event_sources.fuzzy_name_not_found"
+
+ obj custom.Source
+ rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventSourceFunc)
+ dcByFuzzyName = acceptance.InitDataSourceCheck(byFuzzyName)
+ dcFuzzyNameNotFound = acceptance.InitDataSourceCheck(fuzzyNameNotFound)
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ acceptance.TestAccPreCheck(t)
+ acceptance.TestAccPreCheckEgChannelId(t)
+ },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccDataCustomEventSources_filterByFuzzyName(),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ dcByFuzzyName.CheckResourceExists(),
+ resource.TestCheckOutput("is_fuzzy_name_filter_useful", "true"),
+ dcFuzzyNameNotFound.CheckResourceExists(),
+ resource.TestCheckOutput("fuzzy_name_not_found_validation_pass", "true"),
+ ),
+ },
+ },
+ })
+}
+
+func testAccDataCustomEventSources_filterByFuzzyName() string {
+ randUUID, _ := uuid.GenerateUUID()
+
+ return fmt.Sprintf(`
+%[1]s
+
+data "huaweicloud_eg_custom_event_sources" "filter_by_fuzzy_name" {
+ depends_on = [
+ huaweicloud_eg_custom_event_source.test,
+ ]
+
+ fuzzy_name = huaweicloud_eg_custom_event_source.test.name
+}
+
+data "huaweicloud_eg_custom_event_sources" "fuzzy_name_not_found" {
+ // Since a random name is used, there is no dependency relationship with resource attachment, and the dependency needs
+ // to be manually set.
+ depends_on = [
+ huaweicloud_eg_custom_event_source.test,
+ ]
+
+ fuzzy_name = "%[2]s"
+}
+
+locals {
+ filter_result = [for v in data.huaweicloud_eg_custom_event_sources.filter_by_fuzzy_name.sources[*].name :
+ length(regexall("${huaweicloud_eg_custom_event_source.test.name}", v)) > 0]
+}
+
+output "is_fuzzy_name_filter_useful" {
+ value = alltrue(local.filter_result) && length(local.filter_result) > 0
+}
+
+output "fuzzy_name_not_found_validation_pass" {
+ value = length(data.huaweicloud_eg_custom_event_sources.fuzzy_name_not_found.sources) == 0
+}
+`, testAccDataCustomEventSources_base(), randUUID)
+}
+
+func TestAccDataCustomEventSources_filterBySort(t *testing.T) {
+ var (
+ baseRes = "huaweicloud_eg_custom_event_source.test"
+ bySort = "data.huaweicloud_eg_custom_event_sources.filter_by_sort"
+
+ obj custom.Source
+ rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventSourceFunc)
+ dcBySort = acceptance.InitDataSourceCheck(bySort)
+ )
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() {
+ acceptance.TestAccPreCheck(t)
+ acceptance.TestAccPreCheckEgChannelId(t)
+ },
+ ProviderFactories: acceptance.TestAccProviderFactories,
+ CheckDestroy: rc.CheckResourceDestroy(),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccDataCustomEventSources_filterBySort(),
+ Check: resource.ComposeTestCheckFunc(
+ rc.CheckResourceExists(),
+ dcBySort.CheckResourceExists(),
+ resource.TestCheckResourceAttr(bySort, "sources.#", "1"),
+ ),
+ },
+ },
+ })
+}
+
+func testAccDataCustomEventSources_filterBySort() string {
+ name := acceptance.RandomAccResourceName()
+
+ return fmt.Sprintf(`
+resource "huaweicloud_eg_custom_event_source" "test" {
+ channel_id = "%[1]s"
+ name = "%[2]s"
+}
+
+data "huaweicloud_eg_custom_event_sources" "filter_by_sort" {
+ depends_on = [
+ huaweicloud_eg_custom_event_source.test,
+ ]
+
+ sort = "created_time:asc"
+}
+
+output "is_sort_filter_useful" {
+ value = length(data.huaweicloud_eg_custom_event_sources.filter_by_sort.sources) > 0
+}
+`, acceptance.HW_EG_CHANNEL_ID, name)
+}
diff --git a/huaweicloud/services/acceptance/eg/resource_huaweicloud_eg_connection_test.go b/huaweicloud/services/acceptance/eg/resource_huaweicloud_eg_connection_test.go
index 81b20f6169a..1db1c9484ae 100644
--- a/huaweicloud/services/acceptance/eg/resource_huaweicloud_eg_connection_test.go
+++ b/huaweicloud/services/acceptance/eg/resource_huaweicloud_eg_connection_test.go
@@ -81,6 +81,7 @@ func TestAccConnection_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(rName, "status"),
resource.TestCheckResourceAttrSet(rName, "created_at"),
resource.TestCheckResourceAttrSet(rName, "updated_at"),
+ resource.TestCheckResourceAttrSet(rName, "agency"),
),
},
{
@@ -157,6 +158,11 @@ func TestAccConnection_kafka(t *testing.T) {
"huaweicloud_dms_kafka_instance.test", "connect_address"),
resource.TestCheckResourceAttrSet(rName, "status"),
resource.TestCheckResourceAttrSet(rName, "created_at"),
+ resource.TestCheckResourceAttrSet(rName, "flavor"),
+ resource.TestCheckResourceAttrSet(rName, "flavor.0.bandwidth_type"),
+ resource.TestCheckResourceAttrSet(rName, "flavor.0.concurrency"),
+ resource.TestCheckResourceAttrSet(rName, "flavor.0.concurrency_type"),
+ resource.TestCheckResourceAttrSet(rName, "flavor.0.name"),
),
},
{
diff --git a/huaweicloud/services/eg/data_source_huaweicloud_eg_connections.go b/huaweicloud/services/eg/data_source_huaweicloud_eg_connections.go
index 19724895df2..444cab31704 100644
--- a/huaweicloud/services/eg/data_source_huaweicloud_eg_connections.go
+++ b/huaweicloud/services/eg/data_source_huaweicloud_eg_connections.go
@@ -119,6 +119,11 @@ func DataSourceConnections() *schema.Resource {
Description: `The number of confirmation signals the producer
needs to receive to consider the message sent successfully.`,
},
+ "address": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The connection address of Kafka instance.`,
+ },
},
},
Description: `The Kafka detail information for the connection.`,
@@ -300,6 +305,7 @@ func flattenConnectionKafkaDetail(kafkaDetail interface{}) []interface{} {
"enable_sasl_ssl": utils.PathSearch("enable_sasl_ssl", kafkaDetail, nil),
"user_name": utils.PathSearch("user_name", kafkaDetail, nil),
"acks": utils.PathSearch("acks", kafkaDetail, nil),
+ "address": utils.PathSearch("addr", kafkaDetail, nil),
},
}
}
diff --git a/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_channels.go b/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_channels.go
index 62c2a0c06a5..207dd9331ac 100644
--- a/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_channels.go
+++ b/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_channels.go
@@ -46,6 +46,16 @@ func DataSourceCustomEventChannels() *schema.Resource {
Optional: true,
Description: `The channel name used to query specified custom event channel.`,
},
+ "fuzzy_name": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `The name of the channels to be queried for fuzzy matching.`,
+ },
+ "sort": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `The sorting method for query results.`,
+ },
"enterprise_project_id": {
Type: schema.TypeString,
Optional: true,
@@ -112,6 +122,12 @@ func buildEventChannelsQueryParams(d *schema.ResourceData, providerTypeInput ...
if channelId, ok := d.GetOk("channel_id"); ok {
res = fmt.Sprintf("%s&channel_id=%v", res, channelId)
}
+ if sort, ok := d.GetOk("sort"); ok {
+ res = fmt.Sprintf("%s&sort=%v", res, sort)
+ }
+ if fuzzyName, ok := d.GetOk("fuzzy_name"); ok {
+ res = fmt.Sprintf("%s&fuzzy_name=%v", res, fuzzyName)
+ }
if len(providerTypeInput) > 0 {
res = fmt.Sprintf("%s&provider_type=%v", res, providerTypeInput[0])
diff --git a/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_sources.go b/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_sources.go
index 512e57f8677..2226cc798fc 100644
--- a/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_sources.go
+++ b/huaweicloud/services/eg/data_source_huaweicloud_eg_custom_event_sources.go
@@ -43,6 +43,18 @@ func DataSourceCustomEventSources() *schema.Resource {
Optional: true,
Description: `The event source name used to query specified custom event source.`,
},
+ "fuzzy_name": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `The name of the channels to be queried for fuzzy matching.`,
+ },
+ "sort": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `The sorting method for query results.`,
+ },
+
+ // Attributes
"sources": {
Type: schema.TypeList,
Computed: true,
@@ -93,6 +105,12 @@ func DataSourceCustomEventSources() *schema.Resource {
Computed: true,
Description: `The update time of the custom event source.`,
},
+ "error_info": {
+ Type: schema.TypeList,
+ Computed: true,
+ Description: `The error information of the custom event source.`,
+ Elem: errorInfoSchema(),
+ },
},
},
},
@@ -100,6 +118,28 @@ func DataSourceCustomEventSources() *schema.Resource {
}
}
+func errorInfoSchema() *schema.Resource {
+ return &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "error_code": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The error code of current source.`,
+ },
+ "error_detail": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The error detail of current source.`,
+ },
+ "error_msg": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The error message of current source.`,
+ },
+ },
+ }
+}
+
func buildEventSourcesQueryParams(d *schema.ResourceData, providerTypeInput ...string) string {
res := ""
if sourceName, ok := d.GetOk("name"); ok {
@@ -108,6 +148,12 @@ func buildEventSourcesQueryParams(d *schema.ResourceData, providerTypeInput ...s
if channelId, ok := d.GetOk("channel_id"); ok {
res = fmt.Sprintf("%s&channel_id=%v", res, channelId)
}
+ if fuzzyName, ok := d.GetOk("fuzzy_name"); ok {
+ res = fmt.Sprintf("%s&fuzzy_name=%v", res, fuzzyName)
+ }
+ if sort, ok := d.GetOk("sort"); ok {
+ res = fmt.Sprintf("%s&sort=%v", res, sort)
+ }
if len(providerTypeInput) > 0 {
res = fmt.Sprintf("%s&provider_type=%v", res, providerTypeInput[0])
@@ -174,6 +220,8 @@ func flattenDataCustomEventSources(eventSources []interface{}) []interface{} {
"status": utils.PathSearch("status", eventSource, nil),
"created_at": utils.PathSearch("created_at", eventSource, nil),
"updated_at": utils.PathSearch("updated_at", eventSource, nil),
+ "error_info": flattenConnectionErrorInfo(utils.PathSearch(
+ "error_info", eventSource, make(map[string]interface{})).(map[string]interface{})),
})
}
diff --git a/huaweicloud/services/eg/resource_huaweicloud_eg_connection.go b/huaweicloud/services/eg/resource_huaweicloud_eg_connection.go
index b8529711ac6..51f34d7f839 100644
--- a/huaweicloud/services/eg/resource_huaweicloud_eg_connection.go
+++ b/huaweicloud/services/eg/resource_huaweicloud_eg_connection.go
@@ -80,11 +80,24 @@ func ResourceConnection() *schema.Resource {
ForceNew: true,
Description: `Specifies the configuration details of the kafka intance.`,
},
+
+ // Attributes
"status": {
Type: schema.TypeString,
Computed: true,
Description: `Indicates the status of the connection.`,
},
+ "agency": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The user-delegated name used for private network target connection.`,
+ },
+ "flavor": {
+ Type: schema.TypeList,
+ Elem: connectionKafkaFlavorSchema(),
+ Computed: true,
+ Description: `The configuration details of the kafka instance.`,
+ },
"created_at": {
Type: schema.TypeString,
Computed: true,
@@ -106,20 +119,20 @@ func connectionKafkaDetailSchema() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
- Description: `Specifies the ID of the kafka intance.`,
+ Description: `Specifies the ID of the kafka instance.`,
},
"connect_address": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
- Description: `Specifies the IP address of the kafka intance.`,
+ Description: `Specifies the IP address of the kafka instance.`,
},
"user_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
- Description: `Specifies the user name of the kafka intance.`,
+ Description: `Specifies the user name of the kafka instance.`,
},
"password": {
Type: schema.TypeString,
@@ -127,7 +140,7 @@ func connectionKafkaDetailSchema() *schema.Resource {
Computed: true,
ForceNew: true,
Sensitive: true,
- Description: `Specifies the password of the kafka intance.`,
+ Description: `Specifies the password of the kafka instance.`,
},
"acks": {
Type: schema.TypeString,
@@ -137,6 +150,41 @@ func connectionKafkaDetailSchema() *schema.Resource {
Description: `Specifies the number of confirmation signals the procuder
needs to receive to consider the message sent successfully.`,
},
+ "security_protocol": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ Description: `Specifies the security protocol of the kafka instance.`,
+ },
+ },
+ }
+ return &sc
+}
+
+func connectionKafkaFlavorSchema() *schema.Resource {
+ sc := schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "bandwidth_type": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The bandwidth type of the kafka instance.`,
+ },
+ "concurrency": {
+ Type: schema.TypeInt,
+ Computed: true,
+ Description: `The concurrency number of the kafka instance..`,
+ },
+ "concurrency_type": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The concurrency type of the kafka instance.`,
+ },
+ "name": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `The name of the kafka instance.`,
+ },
},
}
return &sc
@@ -210,9 +258,10 @@ func buildCreateConnectionRequestBodyKafkaDetail(rawParams interface{}) map[stri
}
params := map[string]interface{}{
- "instance_id": utils.ValueIgnoreEmpty(raw["instance_id"]),
- "addr": utils.ValueIgnoreEmpty(raw["connect_address"]),
- "acks": utils.ValueIgnoreEmpty(raw["acks"]),
+ "instance_id": utils.ValueIgnoreEmpty(raw["instance_id"]),
+ "addr": utils.ValueIgnoreEmpty(raw["connect_address"]),
+ "acks": utils.ValueIgnoreEmpty(raw["acks"]),
+ "security_protocol": utils.ValueIgnoreEmpty(raw["security_protocol"]),
}
if raw["user_name"].(string) != "" {
@@ -273,7 +322,9 @@ func resourceConnectionRead(_ context.Context, d *schema.ResourceData, meta inte
d.Set("description", utils.PathSearch("description", getConnectionRespBody, nil)),
d.Set("type", utils.PathSearch("type", getConnectionRespBody, nil)),
d.Set("kafka_detail", flattenGetConnectionResponseBodyKafkaDetail(getConnectionRespBody)),
+ d.Set("flavor", flattenGetConnectionResponseBodyKafkaFlavor(getConnectionRespBody)),
d.Set("status", utils.PathSearch("status", getConnectionRespBody, nil)),
+ d.Set("agency", utils.PathSearch("agency", getConnectionRespBody, nil)),
d.Set("created_at", utils.PathSearch("created_time", getConnectionRespBody, nil)),
d.Set("updated_at", utils.PathSearch("updated_time", getConnectionRespBody, nil)),
)
@@ -290,11 +341,12 @@ func flattenGetConnectionResponseBodyKafkaDetail(resp interface{}) []interface{}
rst = []interface{}{
map[string]interface{}{
- "instance_id": utils.PathSearch("instance_id", curJson, nil),
- "connect_address": utils.PathSearch("addr", curJson, nil),
- "user_name": utils.PathSearch("username", curJson, nil),
- "password": utils.PathSearch("password", curJson, nil),
- "acks": utils.PathSearch("acks", curJson, nil),
+ "instance_id": utils.PathSearch("instance_id", curJson, nil),
+ "connect_address": utils.PathSearch("addr", curJson, nil),
+ "user_name": utils.PathSearch("username", curJson, nil),
+ "password": utils.PathSearch("password", curJson, nil),
+ "acks": utils.PathSearch("acks", curJson, nil),
+ "security_protocol": utils.PathSearch("security_protocol", curJson, nil),
},
}
return rst
@@ -380,3 +432,21 @@ func resourceConnectionDelete(_ context.Context, d *schema.ResourceData, meta in
return nil
}
+
+func flattenGetConnectionResponseBodyKafkaFlavor(resp interface{}) []interface{} {
+ var rst []interface{}
+ curJson := utils.PathSearch("flavor", resp, make(map[string]interface{})).(map[string]interface{})
+ if len(curJson) < 1 {
+ return rst
+ }
+
+ rst = []interface{}{
+ map[string]interface{}{
+ "bandwidth_type": utils.PathSearch("bandwidth_type", curJson, nil),
+ "concurrency": utils.PathSearch("concurrency", curJson, nil),
+ "concurrency_type": utils.PathSearch("concurrency_type", curJson, nil),
+ "name": utils.PathSearch("name", curJson, nil),
+ },
+ }
+ return rst
+}