@@ -40,7 +40,7 @@ import (
4040
4141 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
4242 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
43- tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525 "
43+ monitor "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor/v20180724 "
4444 "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
4545)
4646
@@ -292,23 +292,23 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
292292 logId := getLogId (contextNil )
293293
294294 var (
295- request = tke .NewCreatePrometheusAlertPolicyRequest ()
296- response * tke .CreatePrometheusAlertPolicyResponse
295+ request = monitor .NewCreatePrometheusAlertPolicyRequest ()
296+ response * monitor .CreatePrometheusAlertPolicyResponse
297297 )
298298
299299 if v , ok := d .GetOk ("instance_id" ); ok {
300300 request .InstanceId = helper .String (v .(string ))
301301 }
302302
303303 if dMap , ok := helper .InterfacesHeadMap (d , "alert_rule" ); ok {
304- prometheusAlertPolicyItem := tke .PrometheusAlertPolicyItem {}
304+ prometheusAlertPolicyItem := monitor .PrometheusAlertPolicyItem {}
305305 if v , ok := dMap ["name" ]; ok {
306306 prometheusAlertPolicyItem .Name = helper .String (v .(string ))
307307 }
308308 if v , ok := dMap ["rules" ]; ok {
309309 for _ , item := range v .([]interface {}) {
310310 RulesMap := item .(map [string ]interface {})
311- prometheusAlertRule := tke .PrometheusAlertRule {}
311+ prometheusAlertRule := monitor .PrometheusAlertRule {}
312312 if v , ok := RulesMap ["name" ]; ok {
313313 prometheusAlertRule .Name = helper .String (v .(string ))
314314 }
@@ -327,7 +327,7 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
327327 if v , ok := RulesMap ["labels" ]; ok {
328328 for _ , item := range v .([]interface {}) {
329329 labelsMap := item .(map [string ]interface {})
330- label := tke .Label {}
330+ label := monitor .Label {}
331331 if v , ok := labelsMap ["name" ]; ok {
332332 label .Name = helper .String (v .(string ))
333333 }
@@ -340,7 +340,7 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
340340 if v , ok := RulesMap ["annotations" ]; ok {
341341 for _ , item := range v .([]interface {}) {
342342 AnnotationsMap := item .(map [string ]interface {})
343- label := tke .Label {}
343+ label := monitor .Label {}
344344 if v , ok := AnnotationsMap ["name" ]; ok {
345345 label .Name = helper .String (v .(string ))
346346 }
@@ -363,7 +363,7 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
363363 prometheusAlertPolicyItem .TemplateId = helper .String (v .(string ))
364364 }
365365 if NotificationMap , ok := helper .InterfaceToMap (dMap , "notification" ); ok {
366- prometheusNotificationItem := tke .PrometheusNotificationItem {}
366+ prometheusNotificationItem := monitor .PrometheusNotificationItem {}
367367 if v , ok := NotificationMap ["enabled" ]; ok {
368368 prometheusNotificationItem .Enabled = helper .Bool (v .(bool ))
369369 }
@@ -374,7 +374,7 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
374374 prometheusNotificationItem .WebHook = helper .String (v .(string ))
375375 }
376376 if AlertManagerMap , ok := helper .InterfaceToMap (NotificationMap , "alert_manager" ); ok {
377- prometheusAlertManagerConfig := tke .PrometheusAlertManagerConfig {}
377+ prometheusAlertManagerConfig := monitor .PrometheusAlertManagerConfig {}
378378 if v , ok := AlertManagerMap ["url" ]; ok {
379379 prometheusAlertManagerConfig .Url = helper .String (v .(string ))
380380 }
@@ -440,7 +440,7 @@ func resourceTencentCloudTkeTmpAlertPolicyCreate(d *schema.ResourceData, meta in
440440 }
441441
442442 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
443- result , e := meta .(* TencentCloudClient ).apiV3Conn .UseTkeClient ().CreatePrometheusAlertPolicy (request )
443+ result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMonitorClient ().CreatePrometheusAlertPolicy (request )
444444 if e != nil {
445445 return retryError (e )
446446 } else {
@@ -478,7 +478,7 @@ func resourceTencentCloudTkeTmpAlertPolicyRead(d *schema.ResourceData, meta inte
478478 instanceId := ids [0 ]
479479 tmpAlertPolicyId := ids [1 ]
480480
481- service := TkeService {client : meta .(* TencentCloudClient ).apiV3Conn }
481+ service := MonitorService {client : meta .(* TencentCloudClient ).apiV3Conn }
482482 tmpAlertPolicy , err := service .DescribeTkeTmpAlertPolicy (ctx , instanceId , tmpAlertPolicyId )
483483 if err != nil {
484484 return err
@@ -588,7 +588,7 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
588588
589589 logId := getLogId (contextNil )
590590
591- request := tke .NewModifyPrometheusAlertPolicyRequest ()
591+ request := monitor .NewModifyPrometheusAlertPolicyRequest ()
592592
593593 ids := strings .Split (d .Id (), FILED_SP )
594594 if len (ids ) != 2 {
@@ -607,14 +607,14 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
607607 return fmt .Errorf ("`alert_rule` do not support change now." )
608608 }
609609 if dMap , ok := helper .InterfacesHeadMap (d , "alert_rule" ); ok {
610- prometheusAlertPolicyItem := tke .PrometheusAlertPolicyItem {}
610+ prometheusAlertPolicyItem := monitor .PrometheusAlertPolicyItem {}
611611 if v , ok := dMap ["name" ]; ok {
612612 prometheusAlertPolicyItem .Name = helper .String (v .(string ))
613613 }
614614 if v , ok := dMap ["rules" ]; ok {
615615 for _ , item := range v .([]interface {}) {
616616 RulesMap := item .(map [string ]interface {})
617- prometheusAlertRule := tke .PrometheusAlertRule {}
617+ prometheusAlertRule := monitor .PrometheusAlertRule {}
618618 if v , ok := RulesMap ["name" ]; ok {
619619 prometheusAlertRule .Name = helper .String (v .(string ))
620620 }
@@ -633,7 +633,7 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
633633 if v , ok := RulesMap ["annotations" ]; ok {
634634 for _ , item := range v .([]interface {}) {
635635 AnnotationsMap := item .(map [string ]interface {})
636- label := tke .Label {}
636+ label := monitor .Label {}
637637 if v , ok := AnnotationsMap ["name" ]; ok {
638638 label .Name = helper .String (v .(string ))
639639 }
@@ -656,7 +656,7 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
656656 prometheusAlertPolicyItem .TemplateId = helper .String (v .(string ))
657657 }
658658 if NotificationMap , ok := helper .InterfaceToMap (dMap , "notification" ); ok {
659- prometheusNotificationItem := tke .PrometheusNotificationItem {}
659+ prometheusNotificationItem := monitor .PrometheusNotificationItem {}
660660 if v , ok := NotificationMap ["enabled" ]; ok {
661661 prometheusNotificationItem .Enabled = helper .Bool (v .(bool ))
662662 }
@@ -667,7 +667,7 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
667667 prometheusNotificationItem .WebHook = helper .String (v .(string ))
668668 }
669669 if AlertManagerMap , ok := helper .InterfaceToMap (NotificationMap , "alert_manager" ); ok {
670- prometheusAlertManagerConfig := tke .PrometheusAlertManagerConfig {}
670+ prometheusAlertManagerConfig := monitor .PrometheusAlertManagerConfig {}
671671 if v , ok := AlertManagerMap ["url" ]; ok {
672672 prometheusAlertManagerConfig .Url = helper .String (v .(string ))
673673 }
@@ -733,7 +733,7 @@ func resourceTencentCloudTkeTmpAlertPolicyUpdate(d *schema.ResourceData, meta in
733733 }
734734
735735 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
736- result , e := meta .(* TencentCloudClient ).apiV3Conn .UseTkeClient ().ModifyPrometheusAlertPolicy (request )
736+ result , e := meta .(* TencentCloudClient ).apiV3Conn .UseMonitorClient ().ModifyPrometheusAlertPolicy (request )
737737 if e != nil {
738738 return retryError (e )
739739 } else {
@@ -757,7 +757,7 @@ func resourceTencentCloudTkeTmpAlertPolicyDelete(d *schema.ResourceData, meta in
757757 logId := getLogId (contextNil )
758758 ctx := context .WithValue (context .TODO (), logIdKey , logId )
759759
760- service := TkeService {client : meta .(* TencentCloudClient ).apiV3Conn }
760+ service := MonitorService {client : meta .(* TencentCloudClient ).apiV3Conn }
761761 ids := strings .Split (d .Id (), FILED_SP )
762762 if len (ids ) != 2 {
763763 return fmt .Errorf ("id is broken, id is %s" , d .Id ())
0 commit comments