Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_bot_channel_direct_line_speech - support for cognitive_service_id #23106

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down Expand Up @@ -64,6 +65,12 @@ func resourceBotChannelDirectLineSpeech() *pluginsdk.Resource {

"cognitive_service_location": commonschema.LocationWithoutForceNew(),

"cognitive_account_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: cognitiveservicesaccounts.ValidateAccountID,
},

"custom_speech_model_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -112,6 +119,11 @@ func resourceBotChannelDirectLineSpeechCreate(d *pluginsdk.ResourceData, meta in
Kind: botservice.KindBot,
}

if v, ok := d.GetOk("cognitive_account_id"); ok {
channel, _ := channel.Properties.AsDirectLineSpeechChannel()
channel.Properties.CognitiveServiceResourceID = utils.String(v.(string))
}

if v, ok := d.GetOk("custom_speech_model_id"); ok {
channel, _ := channel.Properties.AsDirectLineSpeechChannel()
channel.Properties.CustomSpeechModelID = utils.String(v.(string))
Expand Down Expand Up @@ -158,6 +170,7 @@ func resourceBotChannelDirectLineSpeechRead(d *pluginsdk.ResourceData, meta inte
if props := resp.Properties; props != nil {
if channel, ok := props.AsDirectLineSpeechChannel(); ok {
if channelProps := channel.Properties; channelProps != nil {
d.Set("cognitive_account_id", channelProps.CognitiveServiceResourceID)
d.Set("custom_speech_model_id", channelProps.CustomSpeechModelID)
d.Set("custom_voice_deployment_id", channelProps.CustomVoiceDeploymentID)
}
Expand Down Expand Up @@ -191,6 +204,11 @@ func resourceBotChannelDirectLineSpeechUpdate(d *pluginsdk.ResourceData, meta in
Kind: botservice.KindBot,
}

if v, ok := d.GetOk("cognitive_account_id"); ok {
stephybun marked this conversation as resolved.
Show resolved Hide resolved
channel, _ := channel.Properties.AsDirectLineSpeechChannel()
channel.Properties.CognitiveServiceResourceID = utils.String(v.(string))
}

if v, ok := d.GetOk("custom_speech_model_id"); ok {
channel, _ := channel.Properties.AsDirectLineSpeechChannel()
channel.Properties.CustomSpeechModelID = utils.String(v.(string))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ resource "azurerm_bot_channel_direct_line_speech" "test" {
bot_name = azurerm_bot_channels_registration.test.name
location = azurerm_bot_channels_registration.test.location
resource_group_name = azurerm_resource_group.test.name
cognitive_account_id = azurerm_cognitive_account.test.id
cognitive_service_location = azurerm_cognitive_account.test.location
cognitive_service_access_key = azurerm_cognitive_account.test.primary_access_key
custom_speech_model_id = "a9316355-7b04-4468-9f6e-114419e6c9cc"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/bot_channel_direct_line_speech.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ The following arguments are supported:

* `bot_name` - (Required) The name of the Bot Resource this channel will be associated with. Changing this forces a new resource to be created.

* `cognitive_account_id` - (Optional) The ID of the Cognitive Account this Bot Channel should be associated with.

* `cognitive_service_access_key` - (Required) The access key to access the Cognitive Service.

* `cognitive_service_location` - (Required) Specifies the supported Azure location where the Cognitive Service resource exists.
Expand Down