From d95deeb391a786e77b71be5b61705533fa467269 Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Tue, 7 Feb 2023 07:34:09 +0800 Subject: [PATCH] `azurerm_media_streaming_locator` - support for `filter_names` property (#20274) Co-authored-by: Zhenhua Hu --- .../media/media_streaming_locator_resource.go | 15 +++++++++++++++ .../media_streaming_locator_resource_test.go | 7 +++++++ .../docs/r/media_streaming_locator.html.markdown | 9 +++++++++ 3 files changed, 31 insertions(+) diff --git a/internal/services/media/media_streaming_locator_resource.go b/internal/services/media/media_streaming_locator_resource.go index 85dba06134f3..c331710a6617 100644 --- a/internal/services/media/media_streaming_locator_resource.go +++ b/internal/services/media/media_streaming_locator_resource.go @@ -151,6 +151,16 @@ func resourceMediaStreamingLocator() *pluginsdk.Resource { ValidateFunc: validation.IsRFC3339Time, }, + "filter_names": { + Type: pluginsdk.TypeList, + Optional: true, + ForceNew: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + "start_time": { Type: pluginsdk.TypeString, Optional: true, @@ -218,6 +228,10 @@ func resourceMediaStreamingLocatorCreate(d *pluginsdk.ResourceData, meta interfa } } + if filters, ok := d.GetOk("filter_names"); ok { + payload.Properties.Filters = utils.ExpandStringSlice(filters.([]interface{})) + } + if startTimeRaw, ok := d.GetOk("start_time"); ok { if startTimeRaw.(string) != "" { startTime, err := date.ParseTime(time.RFC3339, startTimeRaw.(string)) @@ -287,6 +301,7 @@ func resourceMediaStreamingLocatorRead(d *pluginsdk.ResourceData, meta interface endTime = t.Format(time.RFC3339) } d.Set("end_time", endTime) + d.Set("filter_names", utils.FlattenStringSlice(props.Filters)) startTime := "" if props.StartTime != nil { diff --git a/internal/services/media/media_streaming_locator_resource_test.go b/internal/services/media/media_streaming_locator_resource_test.go index d8fce68395e0..bd60b443fa29 100644 --- a/internal/services/media/media_streaming_locator_resource_test.go +++ b/internal/services/media/media_streaming_locator_resource_test.go @@ -141,6 +141,12 @@ func (r StreamingLocatorResource) complete(data acceptance.TestData) string { return fmt.Sprintf(` %s +resource "azurerm_media_services_account_filter" "test" { + name = "Filter-1" + resource_group_name = azurerm_resource_group.test.name + media_services_account_name = azurerm_media_services_account.test.name +} + resource "azurerm_media_streaming_locator" "test" { name = "Job-1" resource_group_name = azurerm_resource_group.test.name @@ -151,6 +157,7 @@ resource "azurerm_media_streaming_locator" "test" { end_time = "2028-12-31T23:59:59Z" streaming_locator_id = "90000000-0000-0000-0000-000000000000" alternative_media_id = "my-Alternate-MediaID" + filter_names = [azurerm_media_services_account_filter.test.name] } `, r.template(data)) } diff --git a/website/docs/r/media_streaming_locator.html.markdown b/website/docs/r/media_streaming_locator.html.markdown index d8af75a375e0..c0b331f8a264 100644 --- a/website/docs/r/media_streaming_locator.html.markdown +++ b/website/docs/r/media_streaming_locator.html.markdown @@ -37,6 +37,12 @@ resource "azurerm_media_services_account" "example" { } } +resource "azurerm_media_services_account_filter" "example" { + name = "Filter1" + resource_group_name = azurerm_resource_group.example.name + media_services_account_name = azurerm_media_services_account.example.name +} + resource "azurerm_media_asset" "example" { name = "Asset1" resource_group_name = azurerm_resource_group.example.name @@ -50,6 +56,7 @@ resource "azurerm_media_streaming_locator" "example" { media_services_account_name = azurerm_media_services_account.example.name asset_name = azurerm_media_asset.example.name streaming_policy_name = "Predefined_ClearStreamingOnly" + filter_names = [azurerm_media_services_account_filter.example.name] } ``` @@ -77,6 +84,8 @@ The following arguments are supported: * `end_time` - (Optional) The end time of the Streaming Locator. Changing this forces a new Streaming Locator to be created. +* `filter_names` - (Optional) A list of names of asset or account filters which apply to this Streaming Locator. Changing this forces a new Streaming Locator to be created. + * `start_time` - (Optional) The start time of the Streaming Locator. Changing this forces a new Streaming Locator to be created. * `streaming_locator_id` - (Optional) The ID of the Streaming Locator. Changing this forces a new Streaming Locator to be created.