Skip to content

fix(vod): [116206298] update vod resource #2569

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

Merged
merged 9 commits into from
Mar 25, 2024
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
19 changes: 19 additions & 0 deletions .changelog/2569.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```release-note:enhancement
resource/tencentcloud_vod_adaptive_dynamic_streaming_template: Add vcrf, gop, preserve_hdr_switch, codec_tag. Adjust resource unique id to subAppId#templateId.
```

```release-note:enhancement
resource/tencentcloud_vod_image_sprite_template: Add format, type. Adjust resource unique id to subAppId#templateId.
```

```release-note:enhancement
resource/tencentcloud_vod_procedure_template: Update params media_process_task, add ai_analysis_task, ai_recognition_task, review_audio_video_task, type. Adjust resource unique id to subAppId#templateId.
```

```release-note:enhancement
resource/tencentcloud_vod_sample_snapshot_template: Adjust resource unique id to subAppId#templateId.
```

```release-note:enhancement
resource/tencentcloud_vod_snapshot_by_time_offset_template: Add type. Adjust resource unique id to subAppId#templateId.
```

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,44 @@ Provide a resource to create a VOD adaptive dynamic streaming template.
Example Usage

```hcl
resource "tencentcloud_vod_sub_application" "sub_application" {
name = "adaptive-subapplication"
status = "On"
description = "this is sub application"
}

resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
format = "HLS"
name = "tf-adaptive"
sub_app_id = tonumber(split("#", tencentcloud_vod_sub_application.sub_application.id)[1])
drm_type = "SimpleAES"
disable_higher_video_bitrate = false
disable_higher_video_resolution = false
comment = "test"

stream_info {
video {
codec = "libx265"
fps = 4
bitrate = 129
resolution_adaptive = false
width = 128
height = 128
fill_type = "stretch"
}
audio {
codec = "libmp3lame"
bitrate = 129
sample_rate = 44100
audio_channel = "dual"
}
remove_audio = false
}
stream_info {
video {
codec = "libx264"
fps = 4
bitrate = 256
fps = 3
bitrate = 128
}
audio {
codec = "libfdk_aac"
bitrate = 256
sample_rate = 44100
bitrate = 128
sample_rate = 32000
}
remove_audio = true
tehd_config {
type = "TEHD-100"
}
}
}
```

Import

VOD adaptive dynamic streaming template can be imported using the id, e.g.
VOD adaptive dynamic streaming template can be imported using the id($subAppId#$templateId), e.g.

```
$ terraform import tencentcloud_vod_adaptive_dynamic_streaming_template.foo 169141
$ terraform import tencentcloud_vod_adaptive_dynamic_streaming_template.foo $subAppId#$templateId
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"context"
"fmt"
"strconv"
"strings"
"testing"

tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
svcvod "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/vod"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -53,7 +55,6 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
{
Config: testAccVodAdaptiveDynamicStreamingTemplate,
Check: resource.ComposeTestCheckFunc(
testAccCheckVodAdaptiveDynamicStreamingTemplateExists("tencentcloud_vod_adaptive_dynamic_streaming_template.foo"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "format", "HLS"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "name", "tf-adaptive"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "drm_type", "SimpleAES"),
Expand Down Expand Up @@ -81,6 +82,7 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "stream_info.1.remove_audio", "true"),
resource.TestCheckResourceAttrSet("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "create_time"),
resource.TestCheckResourceAttrSet("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "update_time"),
resource.TestCheckResourceAttrSet("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "sub_app_id"),
),
},
{
Expand All @@ -104,13 +106,14 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "stream_info.0.audio.0.sample_rate", "44100"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "stream_info.0.audio.0.audio_channel", "dual"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "stream_info.0.remove_audio", "false"),
resource.TestCheckResourceAttrSet("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "sub_app_id"),
resource.TestCheckResourceAttr("tencentcloud_vod_adaptive_dynamic_streaming_template.foo", "stream_info.0.tehd_config.0.type", "TEHD-100"),
),
},
{
ResourceName: "tencentcloud_vod_adaptive_dynamic_streaming_template.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"sub_app_id"},
ResourceName: "tencentcloud_vod_adaptive_dynamic_streaming_template.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand All @@ -125,11 +128,13 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateDestroy(s *terraform.State)
if rs.Type != "tencentcloud_vod_adaptive_dynamic_streaming_template" {
continue
}
var (
filter = map[string]interface{}{
"definitions": []string{rs.Primary.ID},
}
)
idSplit := strings.Split(rs.Primary.ID, tccommon.FILED_SP)
subAppId := helper.StrToInt(idSplit[0])
definition := idSplit[1]
filter := map[string]interface{}{
"definitions": []string{definition},
"sub_appid": subAppId,
}

templates, err := vodService.DescribeAdaptiveDynamicStreamingTemplatesByFilter(ctx, filter)
if err != nil {
Expand All @@ -156,9 +161,13 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateExists(n string) resource.Te
return fmt.Errorf("vod adaptive dynamic streaming template id is not set")
}
vodService := svcvod.NewVodService(tcacctest.AccProvider.Meta().(tccommon.ProviderMeta).GetAPIV3Conn())
idSplit := strings.Split(rs.Primary.ID, tccommon.FILED_SP)
subAppId := helper.StrToInt(idSplit[0])
definition := idSplit[1]
var (
filter = map[string]interface{}{
"definitions": []string{rs.Primary.ID},
"definitions": []string{definition},
"sub_appid": subAppId,
}
)

Expand All @@ -174,9 +183,16 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateExists(n string) resource.Te
}

const testAccVodAdaptiveDynamicStreamingTemplate = `
resource "tencentcloud_vod_sub_application" "sub_application" {
name = "adaptive-subapplication"
status = "On"
description = "this is sub application"
}

resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
format = "HLS"
name = "tf-adaptive"
sub_app_id = tonumber(split("#", tencentcloud_vod_sub_application.sub_application.id)[1])
drm_type = "SimpleAES"
disable_higher_video_bitrate = false
disable_higher_video_resolution = false
Expand Down Expand Up @@ -212,9 +228,16 @@ resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
`

const testAccVodAdaptiveDynamicStreamingTemplateUpdate = `
resource "tencentcloud_vod_sub_application" "sub_application" {
name = "adaptive-subapplication"
status = "On"
description = "this is sub application"
}

resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
format = "HLS"
name = "tf-adaptive-update"
sub_app_id = tonumber(split("#", tencentcloud_vod_sub_application.sub_application.id)[1])
drm_type = "SimpleAES"
disable_higher_video_bitrate = true
disable_higher_video_resolution = true
Expand All @@ -237,6 +260,9 @@ resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
audio_channel = "dual"
}
remove_audio = false
tehd_config {
type = "TEHD-100"
}
}
}
`
Loading