@@ -4,38 +4,61 @@ Provides a resource to create a mps adaptive_dynamic_streaming_template
44Example Usage
55
66```hcl
7- resource "tencentcloud_mps_ai_recognition_template" "ai_recognition_template" {
8- name = "terraform-test"
9-
10- asr_full_text_configure {
11- switch = "OFF"
12- }
13-
14- asr_words_configure {
15- label_set = []
16- switch = "OFF"
17- }
18-
19- face_configure {
20- default_library_label_set = [
21- "entertainment",
22- "sport",
23- ]
24- face_library = "All"
25- score = 85
26- switch = "ON"
27- user_define_library_label_set = []
28- }
29-
30- ocr_full_text_configure {
31- switch = "OFF"
7+ resource "tencentcloud_mps_adaptive_dynamic_streaming_template" "adaptive_dynamic_streaming_template" {
8+ comment = "terrraform test"
9+ disable_higher_video_bitrate = 0
10+ disable_higher_video_resolution = 1
11+ format = "HLS"
12+ name = "terrraform-test"
13+
14+ stream_infos {
15+ remove_audio = 0
16+ remove_video = 0
17+
18+ audio {
19+ audio_channel = 1
20+ bitrate = 55
21+ codec = "libmp3lame"
22+ sample_rate = 32000
23+ }
24+
25+ video {
26+ bitrate = 245
27+ codec = "libx264"
28+ fill_type = "black"
29+ fps = 30
30+ gop = 0
31+ height = 135
32+ resolution_adaptive = "open"
33+ vcrf = 0
34+ width = 145
35+ }
3236 }
33-
34- ocr_words_configure {
35- label_set = []
36- switch = "OFF"
37+ stream_infos {
38+ remove_audio = 0
39+ remove_video = 0
40+
41+ audio {
42+ audio_channel = 2
43+ bitrate = 60
44+ codec = "libfdk_aac"
45+ sample_rate = 32000
46+ }
47+
48+ video {
49+ bitrate = 400
50+ codec = "libx264"
51+ fill_type = "black"
52+ fps = 40
53+ gop = 0
54+ height = 150
55+ resolution_adaptive = "open"
56+ vcrf = 0
57+ width = 160
58+ }
3759 }
3860}
61+
3962```
4063
4164Import
@@ -50,7 +73,6 @@ package tencentcloud
5073
5174import (
5275 "context"
53- "fmt"
5476 "log"
5577
5678 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -460,23 +482,25 @@ func resourceTencentCloudMpsAdaptiveDynamicStreamingTemplateUpdate(d *schema.Res
460482
461483 definition := d .Id ()
462484
485+ needChange := false
486+
463487 request .Definition = helper .StrToUint64Point (definition )
464488
465- immutableArgs := []string {"format" , "stream_infos" , "name" , "disable_higher_video_bitrate" , "disable_higher_video_resolution" , "comment" }
489+ mutableArgs := []string {"format" , "stream_infos" , "name" , "disable_higher_video_bitrate" , "disable_higher_video_resolution" , "comment" }
466490
467- for _ , v := range immutableArgs {
491+ for _ , v := range mutableArgs {
468492 if d .HasChange (v ) {
469- return fmt .Errorf ("argument `%s` cannot be changed" , v )
493+ needChange = true
494+ break
470495 }
471496 }
472497
473- if d .HasChange ("format" ) {
498+ if needChange {
499+
474500 if v , ok := d .GetOk ("format" ); ok {
475501 request .Format = helper .String (v .(string ))
476502 }
477- }
478503
479- if d .HasChange ("stream_infos" ) {
480504 if v , ok := d .GetOk ("stream_infos" ); ok {
481505 for _ , item := range v .([]interface {}) {
482506 adaptiveStreamTemplateMap := item .(map [string ]interface {})
@@ -537,44 +561,36 @@ func resourceTencentCloudMpsAdaptiveDynamicStreamingTemplateUpdate(d *schema.Res
537561 request .StreamInfos = append (request .StreamInfos , & adaptiveStreamTemplate )
538562 }
539563 }
540- }
541564
542- if d .HasChange ("name" ) {
543565 if v , ok := d .GetOk ("name" ); ok {
544566 request .Name = helper .String (v .(string ))
545567 }
546- }
547568
548- if d .HasChange ("disable_higher_video_bitrate" ) {
549569 if v , ok := d .GetOkExists ("disable_higher_video_bitrate" ); ok {
550570 request .DisableHigherVideoBitrate = helper .IntUint64 (v .(int ))
551571 }
552- }
553572
554- if d .HasChange ("disable_higher_video_resolution" ) {
555573 if v , ok := d .GetOkExists ("disable_higher_video_resolution" ); ok {
556574 request .DisableHigherVideoResolution = helper .IntUint64 (v .(int ))
557575 }
558- }
559576
560- if d .HasChange ("comment" ) {
561577 if v , ok := d .GetOk ("comment" ); ok {
562578 request .Comment = helper .String (v .(string ))
563579 }
564- }
565580
566- err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
567- result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMpsClient ().ModifyAdaptiveDynamicStreamingTemplate (request )
568- if e != nil {
569- return retryError (e )
570- } else {
571- log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
581+ err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
582+ result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMpsClient ().ModifyAdaptiveDynamicStreamingTemplate (request )
583+ if e != nil {
584+ return retryError (e )
585+ } else {
586+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
587+ }
588+ return nil
589+ })
590+ if err != nil {
591+ log .Printf ("[CRITAL]%s update mps adaptiveDynamicStreamingTemplate failed, reason:%+v" , logId , err )
592+ return err
572593 }
573- return nil
574- })
575- if err != nil {
576- log .Printf ("[CRITAL]%s update mps adaptiveDynamicStreamingTemplate failed, reason:%+v" , logId , err )
577- return err
578594 }
579595
580596 return resourceTencentCloudMpsAdaptiveDynamicStreamingTemplateRead (d , meta )
0 commit comments