From d014e35b9243b9b9af6d5ecc43e5921dbc533896 Mon Sep 17 00:00:00 2001 From: Yun Liu Date: Wed, 6 Jul 2022 15:58:13 +0800 Subject: [PATCH 1/2] Add `database_routing` to azurerm_kusto_iothub_data_connection --- .../kusto_iothub_data_connection_resource.go | 16 ++++++++++++++++ ...kusto_iothub_data_connection_resource_test.go | 2 ++ .../r/kusto_iothub_data_connection.html.markdown | 2 ++ 3 files changed, 20 insertions(+) diff --git a/internal/services/kusto/kusto_iothub_data_connection_resource.go b/internal/services/kusto/kusto_iothub_data_connection_resource.go index 93e87a84609a..cc6b314efd6b 100644 --- a/internal/services/kusto/kusto_iothub_data_connection_resource.go +++ b/internal/services/kusto/kusto_iothub_data_connection_resource.go @@ -121,6 +121,17 @@ func resourceKustoIotHubDataConnection() *pluginsdk.Resource { }, false), }, + "database_routing": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(kusto.DatabaseRoutingSingle), + ValidateFunc: validation.StringInSlice([]string{ + string(kusto.DatabaseRoutingSingle), + string(kusto.DatabaseRoutingMulti), + }, false), + }, + "event_system_properties": { Type: pluginsdk.TypeSet, Optional: true, @@ -173,6 +184,10 @@ func resourceKustoIotHubDataConnectionCreate(d *pluginsdk.ResourceData, meta int IotHubConnectionProperties: iotHubDataConnectionProperties, } + if databaseRouting, ok := d.GetOk("database_routing"); ok { + dataConnection.DatabaseRouting = kusto.DatabaseRouting(databaseRouting.(string)) + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ClusterName, id.DatabaseName, id.Name, dataConnection) if err != nil { return fmt.Errorf("creating or updating %s: %+v", id, err) @@ -218,6 +233,7 @@ func resourceKustoIotHubDataConnectionRead(d *pluginsdk.ResourceData, meta inter d.Set("table_name", props.TableName) d.Set("mapping_rule_name", props.MappingRuleName) d.Set("data_format", props.DataFormat) + d.Set("database_routing", props.DatabaseRouting) d.Set("shared_access_policy_name", props.SharedAccessPolicyName) d.Set("event_system_properties", utils.FlattenStringSlice(props.EventSystemProperties)) } diff --git a/internal/services/kusto/kusto_iothub_data_connection_resource_test.go b/internal/services/kusto/kusto_iothub_data_connection_resource_test.go index cb022f3c9a2b..e265b2cdc1eb 100644 --- a/internal/services/kusto/kusto_iothub_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_iothub_data_connection_resource_test.go @@ -39,6 +39,7 @@ func TestAccKustoIotHubDataConnection_complete(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("database_routing").HasValue("Multi"), ), }, data.ImportStep(), @@ -99,6 +100,7 @@ resource "azurerm_kusto_iothub_data_connection" "test" { event_system_properties = ["message-id", "sequence-number", "to"] mapping_rule_name = "Json_Mapping" data_format = "MULTIJSON" + database_routing = "Multi" } `, r.template(data), data.RandomInteger) } diff --git a/website/docs/r/kusto_iothub_data_connection.html.markdown b/website/docs/r/kusto_iothub_data_connection.html.markdown index 1d1297f5815f..540c9a7c78ae 100644 --- a/website/docs/r/kusto_iothub_data_connection.html.markdown +++ b/website/docs/r/kusto_iothub_data_connection.html.markdown @@ -110,6 +110,8 @@ The following arguments are supported: * `data_format` - (Optional) Specifies the data format of the IoTHub messages. Allowed values: `APACHEAVRO`, `AVRO`, `CSV`, `JSON`, `MULTIJSON`, `ORC`, `PARQUET`, `PSV`, `RAW`, `SCSV`, `SINGLEJSON`, `SOHSV`, `TSV`, `TSVE`, `TXT` and `W3CLOGFILE`. +* `database_routing` - (Optional) Indication for database routing information from the data connection, by default only database routing information is allowed. Allowed values: `Single`, `Multi`. + ## Attributes Reference The following attributes are exported: From 7c2258b7b425149186fe8a2e79e2fc637b72a2d8 Mon Sep 17 00:00:00 2001 From: Yun Liu Date: Fri, 8 Jul 2022 14:28:46 +0800 Subject: [PATCH 2/2] Change `database_routing` to `database_routing_type` --- .../services/kusto/kusto_iothub_data_connection_resource.go | 6 +++--- .../kusto/kusto_iothub_data_connection_resource_test.go | 4 ++-- website/docs/r/kusto_iothub_data_connection.html.markdown | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/kusto/kusto_iothub_data_connection_resource.go b/internal/services/kusto/kusto_iothub_data_connection_resource.go index cc6b314efd6b..8a70245a3085 100644 --- a/internal/services/kusto/kusto_iothub_data_connection_resource.go +++ b/internal/services/kusto/kusto_iothub_data_connection_resource.go @@ -121,7 +121,7 @@ func resourceKustoIotHubDataConnection() *pluginsdk.Resource { }, false), }, - "database_routing": { + "database_routing_type": { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, @@ -184,7 +184,7 @@ func resourceKustoIotHubDataConnectionCreate(d *pluginsdk.ResourceData, meta int IotHubConnectionProperties: iotHubDataConnectionProperties, } - if databaseRouting, ok := d.GetOk("database_routing"); ok { + if databaseRouting, ok := d.GetOk("database_routing_type"); ok { dataConnection.DatabaseRouting = kusto.DatabaseRouting(databaseRouting.(string)) } @@ -233,7 +233,7 @@ func resourceKustoIotHubDataConnectionRead(d *pluginsdk.ResourceData, meta inter d.Set("table_name", props.TableName) d.Set("mapping_rule_name", props.MappingRuleName) d.Set("data_format", props.DataFormat) - d.Set("database_routing", props.DatabaseRouting) + d.Set("database_routing_type", props.DatabaseRouting) d.Set("shared_access_policy_name", props.SharedAccessPolicyName) d.Set("event_system_properties", utils.FlattenStringSlice(props.EventSystemProperties)) } diff --git a/internal/services/kusto/kusto_iothub_data_connection_resource_test.go b/internal/services/kusto/kusto_iothub_data_connection_resource_test.go index e265b2cdc1eb..0a72cef65ead 100644 --- a/internal/services/kusto/kusto_iothub_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_iothub_data_connection_resource_test.go @@ -39,7 +39,7 @@ func TestAccKustoIotHubDataConnection_complete(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("database_routing").HasValue("Multi"), + check.That(data.ResourceName).Key("database_routing_type").HasValue("Multi"), ), }, data.ImportStep(), @@ -100,7 +100,7 @@ resource "azurerm_kusto_iothub_data_connection" "test" { event_system_properties = ["message-id", "sequence-number", "to"] mapping_rule_name = "Json_Mapping" data_format = "MULTIJSON" - database_routing = "Multi" + database_routing_type = "Multi" } `, r.template(data), data.RandomInteger) } diff --git a/website/docs/r/kusto_iothub_data_connection.html.markdown b/website/docs/r/kusto_iothub_data_connection.html.markdown index 540c9a7c78ae..9ee882fd319d 100644 --- a/website/docs/r/kusto_iothub_data_connection.html.markdown +++ b/website/docs/r/kusto_iothub_data_connection.html.markdown @@ -110,7 +110,7 @@ The following arguments are supported: * `data_format` - (Optional) Specifies the data format of the IoTHub messages. Allowed values: `APACHEAVRO`, `AVRO`, `CSV`, `JSON`, `MULTIJSON`, `ORC`, `PARQUET`, `PSV`, `RAW`, `SCSV`, `SINGLEJSON`, `SOHSV`, `TSV`, `TSVE`, `TXT` and `W3CLOGFILE`. -* `database_routing` - (Optional) Indication for database routing information from the data connection, by default only database routing information is allowed. Allowed values: `Single`, `Multi`. +* `database_routing_type` - (Optional) Indication for database routing information from the data connection, by default only database routing information is allowed. Allowed values: `Single`, `Multi`. ## Attributes Reference