@@ -5,34 +5,35 @@ Example Usage
55
66```hcl
77resource "tencentcloud_mps_ai_recognition_template" "ai_recognition_template" {
8- name = <nil>
9- comment = <nil>
10- face_configure {
11- switch = <nil>
12- score =
13- default_library_label_set = <nil>
14- user_define_library_label_set = <nil>
15- face_library = "All"
8+ name = "terraform-test"
169
10+ asr_full_text_configure {
11+ switch = "OFF"
1712 }
18- ocr_full_text_configure {
19- switch = <nil>
2013
14+ asr_words_configure {
15+ label_set = []
16+ switch = "OFF"
2117 }
22- ocr_words_configure {
23- switch = <nil>
24- label_set = <nil>
2518
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 = []
2628 }
27- asr_full_text_configure {
28- switch = <nil>
29- subtitle_format = <nil>
3029
30+ ocr_full_text_configure {
31+ switch = "OFF"
3132 }
32- asr_words_configure {
33- switch = <nil>
34- label_set = <nil>
3533
34+ ocr_words_configure {
35+ label_set = []
36+ switch = "OFF"
3637 }
3738}
3839```
@@ -49,7 +50,6 @@ package tencentcloud
4950
5051import (
5152 "context"
52- "fmt"
5353 "log"
5454
5555 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -451,27 +451,26 @@ func resourceTencentCloudMpsAiRecognitionTemplateUpdate(d *schema.ResourceData,
451451
452452 request .Definition = helper .StrToInt64Point (definition )
453453
454- immutableArgs := []string {"name" , "comment" , "face_configure" , "ocr_full_text_configure" , "ocr_words_configure" , "asr_full_text_configure" , "asr_words_configure" }
454+ mutableArgs := []string {"name" , "comment" , "face_configure" , "ocr_full_text_configure" , "ocr_words_configure" , "asr_full_text_configure" , "asr_words_configure" }
455+
456+ needChange := false
455457
456- for _ , v := range immutableArgs {
458+ for _ , v := range mutableArgs {
457459 if d .HasChange (v ) {
458- return fmt .Errorf ("argument `%s` cannot be changed" , v )
460+ needChange = true
461+ break
459462 }
460463 }
461464
462- if d . HasChange ( "name" ) {
465+ if needChange {
463466 if v , ok := d .GetOk ("name" ); ok {
464467 request .Name = helper .String (v .(string ))
465468 }
466- }
467469
468- if d .HasChange ("comment" ) {
469470 if v , ok := d .GetOk ("comment" ); ok {
470471 request .Comment = helper .String (v .(string ))
471472 }
472- }
473473
474- if d .HasChange ("face_configure" ) {
475474 if dMap , ok := helper .InterfacesHeadMap (d , "face_configure" ); ok {
476475 faceConfigureInfo := mps.FaceConfigureInfoForUpdate {}
477476 if v , ok := dMap ["switch" ]; ok {
@@ -499,19 +498,15 @@ func resourceTencentCloudMpsAiRecognitionTemplateUpdate(d *schema.ResourceData,
499498 }
500499 request .FaceConfigure = & faceConfigureInfo
501500 }
502- }
503501
504- if d .HasChange ("ocr_full_text_configure" ) {
505502 if dMap , ok := helper .InterfacesHeadMap (d , "ocr_full_text_configure" ); ok {
506503 ocrFullTextConfigureInfo := mps.OcrFullTextConfigureInfoForUpdate {}
507504 if v , ok := dMap ["switch" ]; ok {
508505 ocrFullTextConfigureInfo .Switch = helper .String (v .(string ))
509506 }
510507 request .OcrFullTextConfigure = & ocrFullTextConfigureInfo
511508 }
512- }
513509
514- if d .HasChange ("ocr_words_configure" ) {
515510 if dMap , ok := helper .InterfacesHeadMap (d , "ocr_words_configure" ); ok {
516511 ocrWordsConfigureInfo := mps.OcrWordsConfigureInfoForUpdate {}
517512 if v , ok := dMap ["switch" ]; ok {
@@ -526,22 +521,18 @@ func resourceTencentCloudMpsAiRecognitionTemplateUpdate(d *schema.ResourceData,
526521 }
527522 request .OcrWordsConfigure = & ocrWordsConfigureInfo
528523 }
529- }
530524
531- if d .HasChange ("asr_full_text_configure" ) {
532525 if dMap , ok := helper .InterfacesHeadMap (d , "asr_full_text_configure" ); ok {
533526 asrFullTextConfigureInfo := mps.AsrFullTextConfigureInfoForUpdate {}
534527 if v , ok := dMap ["switch" ]; ok {
535528 asrFullTextConfigureInfo .Switch = helper .String (v .(string ))
536529 }
537- if v , ok := dMap ["subtitle_format" ]; ok {
530+ if v , _ := dMap ["subtitle_format" ]; v != "" {
538531 asrFullTextConfigureInfo .SubtitleFormat = helper .String (v .(string ))
539532 }
540533 request .AsrFullTextConfigure = & asrFullTextConfigureInfo
541534 }
542- }
543535
544- if d .HasChange ("asr_words_configure" ) {
545536 if dMap , ok := helper .InterfacesHeadMap (d , "asr_words_configure" ); ok {
546537 asrWordsConfigureInfo := mps.AsrWordsConfigureInfoForUpdate {}
547538 if v , ok := dMap ["switch" ]; ok {
@@ -556,20 +547,20 @@ func resourceTencentCloudMpsAiRecognitionTemplateUpdate(d *schema.ResourceData,
556547 }
557548 request .AsrWordsConfigure = & asrWordsConfigureInfo
558549 }
559- }
560550
561- err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
562- result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMpsClient ().ModifyAIRecognitionTemplate (request )
563- if e != nil {
564- return retryError (e )
565- } else {
566- log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
551+ err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
552+ result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMpsClient ().ModifyAIRecognitionTemplate (request )
553+ if e != nil {
554+ return retryError (e )
555+ } else {
556+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
557+ }
558+ return nil
559+ })
560+ if err != nil {
561+ log .Printf ("[CRITAL]%s update mps aiRecognitionTemplate failed, reason:%+v" , logId , err )
562+ return err
567563 }
568- return nil
569- })
570- if err != nil {
571- log .Printf ("[CRITAL]%s update mps aiRecognitionTemplate failed, reason:%+v" , logId , err )
572- return err
573564 }
574565
575566 return resourceTencentCloudMpsAiRecognitionTemplateRead (d , meta )
0 commit comments