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_media_streaming_locator - support for filter_names property #20274

Merged
merged 2 commits into from
Feb 6, 2023
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
15 changes: 15 additions & 0 deletions internal/services/media/media_streaming_locator_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/media_streaming_locator.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
}
```

Expand Down Expand Up @@ -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.
Expand Down