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_service_azure_bot - support streaming_endpoint_enabled #17423

Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions internal/services/bot/bot_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ func TestAccBotChannelsRegistration(t *testing.T) {
"streamingEndpointEnabled": testAccBotChannelsRegistration_streamingEndpointEnabled,
},
"bot": {
"basic": testAccBotServiceAzureBot_basic,
"completeUpdate": testAccBotServiceAzureBot_completeUpdate,
"msaAppType": testAccBotServiceAzureBot_msaAppType,
"requiresImport": testAccBotServiceAzureBot_requiresImport,
"basic": testAccBotServiceAzureBot_basic,
"completeUpdate": testAccBotServiceAzureBot_completeUpdate,
"msaAppType": testAccBotServiceAzureBot_msaAppType,
"requiresImport": testAccBotServiceAzureBot_requiresImport,
"streamingEndpointEnabled": testAccBotServiceAzureBot_streamingEndpointEnabled,
},
"connection": {
"basic": testAccBotConnection_basic,
Expand Down
47 changes: 47 additions & 0 deletions internal/services/bot/bot_service_azure_bot_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ func testAccBotServiceAzureBot_msaAppType(t *testing.T) {
})
}

func testAccBotServiceAzureBot_streamingEndpointEnabled(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_service_azure_bot", "test")
r := BotServiceAzureBotResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.steamingEndpointEnabled(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.steamingEndpointEnabled(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (t BotServiceAzureBotResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.BotServiceID(state.ID)
if err != nil {
Expand Down Expand Up @@ -223,3 +245,28 @@ resource "azurerm_bot_service_azure_bot" "test" {
}
`, data.RandomInteger, data.Locations.Primary)
}

func (BotServiceAzureBotResource) steamingEndpointEnabled(data acceptance.TestData, streamingEndpointEnabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

data "azurerm_client_config" "current" {
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
location = "%[2]s"
}

resource "azurerm_bot_service_azure_bot" "test" {
name = "acctestdf%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = "global"
sku = "F0"
microsoft_app_id = data.azurerm_client_config.current.client_id
streaming_endpoint_enabled = %[3]t
}
`, data.RandomInteger, data.Locations.Primary, streamingEndpointEnabled)
}
17 changes: 17 additions & 0 deletions internal/services/bot/bot_service_base_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ func (br botBaseResource) arguments(fields map[string]*pluginsdk.Schema) map[str
ValidateFunc: validation.StringIsNotEmpty,
},

"streaming_endpoint_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"tags": tags.Schema(),
}

Expand Down Expand Up @@ -173,6 +179,7 @@ func (br botBaseResource) createFunc(resourceName, botKind string) sdk.ResourceF
DeveloperAppInsightsApplicationID: utils.String(metadata.ResourceData.Get("developer_app_insights_application_id").(string)),
LuisAppIds: utils.ExpandStringSlice(metadata.ResourceData.Get("luis_app_ids").([]interface{})),
LuisKey: utils.String(metadata.ResourceData.Get("luis_key").(string)),
IsStreamingSupported: utils.Bool(metadata.ResourceData.Get("streaming_endpoint_enabled").(bool)),
},
Tags: tags.Expand(metadata.ResourceData.Get("tags").(map[string]interface{})),
}
Expand Down Expand Up @@ -290,6 +297,12 @@ func (br botBaseResource) readFunc() sdk.ResourceFunc {
luisAppIds = *v
}
metadata.ResourceData.Set("luis_app_ids", utils.FlattenStringSlice(&luisAppIds))

streamingEndpointEnabled := false
if v := props.IsStreamingSupported; v != nil {
streamingEndpointEnabled = *v
}
metadata.ResourceData.Set("streaming_endpoint_enabled", streamingEndpointEnabled)
}

return nil
Expand Down Expand Up @@ -359,6 +372,10 @@ func (br botBaseResource) updateFunc() sdk.ResourceFunc {
existing.Properties.LuisKey = utils.String(metadata.ResourceData.Get("luis_key").(string))
}

if metadata.ResourceData.HasChange("streaming_endpoint_enabled") {
existing.Properties.IsStreamingSupported = utils.Bool(metadata.ResourceData.Get("streaming_endpoint_enabled").(bool))
}

if _, err := client.Update(ctx, id.ResourceGroup, id.Name, existing); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/bot_service_azure_bot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ The following arguments are supported:

* `luis_key` - (Optional) The LUIS key to associate with this Azure Bot Service.

* `streaming_endpoint_enabled` - (Optional) Is the streaming endpoint enabled for this Azure Bot Service. Defaults to `false`.

* `tags` - (Optional) A mapping of tags which should be assigned to this Azure Bot Service.

## Attributes Reference
Expand Down