diff --git a/tencentcloud/data_source_tc_monitor_alarm_notices.go b/tencentcloud/data_source_tc_monitor_alarm_notices.go new file mode 100644 index 0000000000..b250b0441a --- /dev/null +++ b/tencentcloud/data_source_tc_monitor_alarm_notices.go @@ -0,0 +1,397 @@ +/* +Use this data source to Interlude notification list. + +Example Usage + +```hcl +data "tencentcloud_monitor_alarm_notices" "notices" { + order = "DESC" + owner_uid = 1 + name = "" + receiver_type = "" + user_ids = [] + group_ids = [] + notice_ids = [] +} +``` + +*/ +package tencentcloud + +import ( + "context" + "crypto/md5" + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + monitor "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor/v20180724" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func dataSourceTencentMonitorAlarmNotices() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentMonitorAlarmNoticesRead, + Schema: map[string]*schema.Schema{ + "order": { + Type: schema.TypeString, + Optional: true, + Default: "ASC", + Description: "Sort by update time ASC=forward order DESC=reverse order.", + }, + "owner_uid": { + Type: schema.TypeInt, + Optional: true, + Description: "The primary account uid is used to create a preset notification.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "Alarm notification template name Used for fuzzy search.", + }, + "receiver_type": { + Type: schema.TypeString, + Optional: true, + Description: "To filter alarm notification templates according to recipients, you need to select the notification user type. USER=user GROUP=user group Leave blank = not filter by recipient.", + }, + "user_ids": { + Type: schema.TypeSet, + Optional: true, + Description: "List of recipients.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "group_ids": { + Type: schema.TypeSet, + Optional: true, + Description: "Receive group list.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "notice_ids": { + Type: schema.TypeSet, + Optional: true, + Description: "Receive group list.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to store results.", + }, + + "alarm_notice": { + Type: schema.TypeList, + Computed: true, + Description: "Alarm notification template list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Alarm notification template ID.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Alarm notification template name.", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Last modified time.", + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + Description: "Last Modified By.", + }, + "notice_type": { + Type: schema.TypeString, + Computed: true, + Description: "Alarm notification type ALARM=Notification not restored OK=Notification restored ALL.", + }, + "user_notices": { + Type: schema.TypeList, + Computed: true, + Description: "Alarm notification template list.(At most five).", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "receiver_type": { + Type: schema.TypeString, + Computed: true, + Description: "Recipient Type USER=User GROUP=User Group.", + }, + "start_time": { + Type: schema.TypeInt, + Computed: true, + Description: "The number of seconds since the notification start time 00:00:00 (value range 0-86399).", + }, + "end_time": { + Type: schema.TypeInt, + Computed: true, + Description: "The number of seconds since the notification end time 00:00:00 (value range 0-86399).", + }, + "notice_way": { + Type: schema.TypeSet, + Computed: true, + Description: "Notification Channel List EMAIL=Mail SMS=SMS CALL=Telephone WECHAT=WeChat RTX=Enterprise WeChat.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "user_ids": { + Type: schema.TypeSet, + Computed: true, + Description: "User UID List.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "group_ids": { + Type: schema.TypeSet, + Computed: true, + Description: "User group ID list.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "phone_order": { + Type: schema.TypeSet, + Computed: true, + Description: "Telephone polling list.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "phone_circle_times": { + Type: schema.TypeInt, + Computed: true, + Description: "Number of telephone polls (value range: 1-5).", + }, + "phone_inner_interval": { + Type: schema.TypeInt, + Computed: true, + Description: "Number of seconds between calls in a polling session (value range: 60-900).", + }, + "phone_circle_interval": { + Type: schema.TypeInt, + Computed: true, + Description: "Number of seconds between polls (value range: 60-900).", + }, + "need_phone_arrive_notice": { + Type: schema.TypeInt, + Computed: true, + Description: "Contact notification required 0= No 1= Yes.", + }, + "phone_call_type": { + Type: schema.TypeString, + Computed: true, + Description: "Call type SYNC= Simultaneous call CIRCLE= Round call If this parameter is not specified, the default value is round call.", + }, + "weekday": { + Type: schema.TypeSet, + Computed: true, + Description: "Notification period 1-7 indicates Monday to Sunday.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + }, + }, + "url_notices": { + Type: schema.TypeList, + Computed: true, + Description: "The maximum number of callback notifications is 3.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Computed: true, + Description: "Callback URL (limited to 256 characters).", + }, + "start_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Notification Start Time Number of seconds at the start of a day.", + }, + "end_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Notification End Time Seconds at the start of a day.", + }, + "weekday": { + Type: schema.TypeSet, + Computed: true, + Description: "Notification period 1-7 indicates Monday to Sunday.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + }, + }, + "cls_notices": { + Type: schema.TypeList, + Computed: true, + Description: "A maximum of one alarm notification can be pushed to the CLS service.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "Regional.", + }, + "log_set_id": { + Type: schema.TypeString, + Computed: true, + Description: "Log collection Id.", + }, + "topic_id": { + Type: schema.TypeString, + Computed: true, + Description: "Theme Id.", + }, + "enable": { + Type: schema.TypeInt, + Computed: true, + Description: "Start-stop status, can not be transmitted, default enabled. 0= Disabled, 1= enabled.", + }, + }, + }, + }, + "is_preset": { + Type: schema.TypeInt, + Computed: true, + Description: "Whether it is the system default notification template 0=No 1=Yes.", + }, + "notice_language": { + Type: schema.TypeString, + Computed: true, + Description: "Notification language zh-CN=Chinese en-US=English.", + }, + "policy_ids": { + Type: schema.TypeSet, + Computed: true, + Description: "List of alarm policy IDs bound to the alarm notification template.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + } +} + +func dataSourceTencentMonitorAlarmNoticesRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_monitor_alarm_notices.read")() + + var ( + monitorService = MonitorService{client: meta.(*TencentCloudClient).apiV3Conn} + err error + alarmNotices []interface{} + alarmNotice []*monitor.AlarmNotice + ) + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + alarmNoticeMap := make(map[string]interface{}) + alarmNoticeMap["order"] = helper.String(d.Get("order").(string)) + + if v, ok := d.GetOk("owner_uid"); ok { + alarmNoticeMap["ownerUid"] = helper.IntInt64(v.(int)) + } + if v, ok := d.GetOk("name"); ok { + alarmNoticeMap["name"] = helper.String(v.(string)) + } + if v, ok := d.GetOk("receiver_type"); ok { + alarmNoticeMap["receiverType"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("user_ids"); ok { + userIds := v.(*schema.Set).List() + userIdsArr := make([]*int64, 0, len(userIds)) + for _, userId := range userIds { + userIdsArr = append(userIdsArr, helper.Int64(userId.(int64))) + } + alarmNoticeMap["userIdArr"] = userIdsArr + } + + if v, ok := d.GetOk("group_ids"); ok { + groupIds := v.(*schema.Set).List() + groupIdsArr := make([]*int64, 0, len(groupIds)) + for _, groupId := range groupIds { + groupIdsArr = append(groupIdsArr, helper.Int64(groupId.(int64))) + } + alarmNoticeMap["groupArr"] = groupIdsArr + } + + if v, ok := d.GetOk("notice_ids"); ok { + noticeIds := v.(*schema.Set).List() + noticeIdsArr := make([]*string, 0, len(noticeIds)) + for _, noticeId := range noticeIds { + noticeIdsArr = append(noticeIdsArr, helper.String(noticeId.(string))) + } + alarmNoticeMap["noticeArr"] = noticeIdsArr + } + + alarmNotice, err = monitorService.DescribeAlarmNoticeById(ctx, alarmNoticeMap) + if err != nil { + return err + } + for _, noticesItem := range alarmNotice { + noticesItemMap := map[string]interface{}{ + "id": noticesItem.Id, + "name": noticesItem.Name, + "updated_at": noticesItem.UpdatedAt, + "updated_by": noticesItem.UpdatedBy, + "notice_type": noticesItem.NoticeType, + "is_preset": noticesItem.IsPreset, + "notice_language": noticesItem.NoticeLanguage, + "policy_ids": noticesItem.PolicyIds, + } + + userNoticesItems := make([]interface{}, 0, 100) + for _, userNotices := range noticesItem.UserNotices { + userNoticesItems = append(userNoticesItems, map[string]interface{}{ + "receiver_type": userNotices.ReceiverType, + "start_time": userNotices.StartTime, + "end_time": userNotices.EndTime, + "notice_way": userNotices.NoticeWay, + "user_ids": userNotices.UserIds, + "group_ids": userNotices.GroupIds, + "phone_order": userNotices.PhoneOrder, + "phone_circle_times": userNotices.PhoneCircleTimes, + "phone_inner_interval": userNotices.PhoneInnerInterval, + "phone_circle_interval": userNotices.PhoneCircleInterval, + "need_phone_arrive_notice": userNotices.NeedPhoneArriveNotice, + "phone_call_type": userNotices.PhoneCallType, + "weekday": userNotices.Weekday, + }) + } + + urlNoticesItems := make([]interface{}, 0, 100) + for _, urlNotice := range noticesItem.URLNotices { + urlNoticesItems = append(urlNoticesItems, map[string]interface{}{ + "url": urlNotice.URL, + "start_time": urlNotice.StartTime, + "end_time": urlNotice.EndTime, + "weekday": urlNotice.Weekday, + }) + } + + clsNoticesItems := make([]interface{}, 0, 100) + for _, clsNotice := range noticesItem.CLSNotices { + clsNoticesItems = append(clsNoticesItems, map[string]interface{}{ + "region": clsNotice.Region, + "log_set_id": clsNotice.LogSetId, + "topic_id": clsNotice.TopicId, + "enable": clsNotice.Enable, + }) + } + noticesItemMap["user_notices"] = userNoticesItems + noticesItemMap["url_notices"] = urlNoticesItems + noticesItemMap["cls_notices"] = clsNoticesItems + alarmNotices = append(alarmNotices, noticesItemMap) + } + + md := md5.New() + id := fmt.Sprintf("%x", md.Sum(nil)) + d.SetId(id) + + if err = d.Set("alarm_notice", alarmNotices); err != nil { + return err + } + if output, ok := d.GetOk("result_output_file"); ok { + return writeToFile(output.(string), alarmNotices) + } + return nil +} diff --git a/tencentcloud/data_source_tc_monitor_alarm_notices_test.go b/tencentcloud/data_source_tc_monitor_alarm_notices_test.go new file mode 100644 index 0000000000..81c94ee049 --- /dev/null +++ b/tencentcloud/data_source_tc_monitor_alarm_notices_test.go @@ -0,0 +1,38 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +func TestAccAlarmNoticesDatasourceBasic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceAlarmNotices(), + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_monitor_alarm_notices.notices"), + //resource.TestCheckResourceAttr("data.tencentcloud_monitor_alarm_notices.notices", "alarm_notice.#", "2"), + resource.TestCheckResourceAttr("data.tencentcloud_monitor_alarm_notices.notices", "order", "DESC"), + resource.TestCheckResourceAttr("data.tencentcloud_monitor_alarm_notices.notices", "owner_uid", "1"), + ), + }, + }, + }) +} + +func testAccDataSourceAlarmNotices() string { + return `data "tencentcloud_monitor_alarm_notices" "notices" { + order = "DESC" + owner_uid = 1 + name = "" + receiver_type = "" + user_ids = [] + group_ids = [] + notice_ids = [] +}` +} diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index 4e3a7b1eeb..8c703adc4f 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -418,6 +418,7 @@ Monitor tencentcloud_monitor_binding_objects tencentcloud_monitor_policy_groups tencentcloud_monitor_product_namespace + tencentcloud_monitor_alarm_notices Resource tencentcloud_monitor_policy_group @@ -434,6 +435,7 @@ Monitor tencentcloud_monitor_tmp_tke_template tencentcloud_monitor_tmp_tke_alert_policy tencentcloud_monitor_tmp_tke_config + tencentcloud_monitor_alarm_notice PostgreSQL Data Source @@ -891,6 +893,7 @@ func Provider() terraform.ResourceProvider { "tencentcloud_monitor_binding_objects": dataSourceTencentMonitorBindingObjects(), "tencentcloud_monitor_policy_groups": dataSourceTencentMonitorPolicyGroups(), "tencentcloud_monitor_product_namespace": dataSourceTencentMonitorProductNamespace(), + "tencentcloud_monitor_alarm_notices": dataSourceTencentMonitorAlarmNotices(), "tencentcloud_elasticsearch_instances": dataSourceTencentCloudElasticsearchInstances(), "tencentcloud_postgresql_instances": dataSourceTencentCloudPostgresqlInstances(), "tencentcloud_postgresql_specinfos": dataSourceTencentCloudPostgresqlSpecinfos(), @@ -1087,6 +1090,7 @@ func Provider() terraform.ResourceProvider { "tencentcloud_monitor_policy_binding_object": resourceTencentCloudMonitorPolicyBindingObject(), "tencentcloud_monitor_binding_receiver": resourceTencentCloudMonitorBindingAlarmReceiver(), "tencentcloud_monitor_alarm_policy": resourceTencentCloudMonitorAlarmPolicy(), + "tencentcloud_monitor_alarm_notice": resourceTencentCloudMonitorAlarmNotice(), "tencentcloud_monitor_tmp_instance": resourceTencentCloudMonitorTmpInstance(), "tencentcloud_monitor_tmp_cvm_agent": resourceTencentCloudMonitorTmpCvmAgent(), "tencentcloud_monitor_tmp_scrape_job": resourceTencentCloudMonitorTmpScrapeJob(), diff --git a/tencentcloud/resource_tc_monitor_alarm_notice.go b/tencentcloud/resource_tc_monitor_alarm_notice.go new file mode 100644 index 0000000000..b4aeb82422 --- /dev/null +++ b/tencentcloud/resource_tc_monitor_alarm_notice.go @@ -0,0 +1,659 @@ +/* +Provides a alarm notice resource for monitor. + +Example Usage + +```hcl +resource "tencentcloud_monitor_alarm_notice" "example" { + name = "test_alarm_notice_1" + notice_type = "ALL" + notice_language = "zh-CN" + + user_notices { + receiver_type = "USER" + start_time = 0 + end_time = 1 + notice_way = ["SMS","EMAIL"] + user_ids = [10001] + group_ids = [] + phone_order = [10001] + phone_circle_times = 2 + phone_circle_interval = 50 + phone_inner_interval = 60 + need_phone_arrive_notice = 1 + phone_call_type = "CIRCLE" + weekday =[1,2,3,4,5,6,7] + } + + url_notices { + url = "https://www.mytest.com/validate" + end_time = 0 + start_time = 1 + weekday = [1,2,3,4,5,6,7] + } + +} +``` + +Import + +Monitor Alarm Notice can be imported, e.g. + +``` +$ terraform import tencentcloud_monitor_alarm_notice.import-test noticeId +``` + +*/ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + monitor "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor/v20180724" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit" +) + +func resourceTencentCloudMonitorAlarmNotice() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentMonitorAlarmNoticeCreate, + Read: resourceTencentMonitorAlarmNoticeRead, + Update: resourceTencentMonitorAlarmNoticeUpdate, + Delete: resourceTencentMonitorAlarmNoticeDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Notification template name within 60.", + }, + "notice_type": { + Type: schema.TypeString, + Required: true, + Description: "Alarm notification type ALARM=Notification not restored OK=Notification restored ALL.", + }, + "notice_language": { + Type: schema.TypeString, + Required: true, + Description: "Notification language zh-CN=Chinese en-US=English.", + }, + "user_notices": { + Type: schema.TypeList, + Optional: true, + Description: "Alarm notification template list.(At most five).", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "receiver_type": { + Type: schema.TypeString, + Required: true, + Description: "Recipient Type USER=User GROUP=User Group.", + }, + "start_time": { + Type: schema.TypeInt, + Required: true, + Description: "The number of seconds since the notification start time 00:00:00 (value range 0-86399).", + }, + "end_time": { + Type: schema.TypeInt, + Required: true, + Description: "The number of seconds since the notification end time 00:00:00 (value range 0-86399).", + }, + "notice_way": { + Type: schema.TypeSet, + Required: true, + Description: "Notification Channel List EMAIL=Mail SMS=SMS CALL=Telephone WECHAT=WeChat RTX=Enterprise WeChat.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "user_ids": { + Type: schema.TypeSet, + Optional: true, + Description: "User UID List.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "group_ids": { + Type: schema.TypeSet, + Optional: true, + Description: "User group ID list.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "phone_order": { + Type: schema.TypeSet, + Optional: true, + Description: "Telephone polling list.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "phone_circle_times": { + Type: schema.TypeInt, + Optional: true, + Description: "Number of telephone polls (value range: 1-5).", + }, + "phone_inner_interval": { + Type: schema.TypeInt, + Optional: true, + Description: "Number of seconds between calls in a polling session (value range: 60-900).", + }, + "phone_circle_interval": { + Type: schema.TypeInt, + Optional: true, + Description: "Number of seconds between polls (value range: 60-900).", + }, + "need_phone_arrive_notice": { + Type: schema.TypeInt, + Optional: true, + Description: "Contact notification required 0= No 1= Yes.", + }, + "phone_call_type": { + Type: schema.TypeString, + Optional: true, + Description: "Call type SYNC= Simultaneous call CIRCLE= Round call If this parameter is not specified, the default value is round call.", + }, + "weekday": { + Type: schema.TypeSet, + Optional: true, + Description: "Notification period 1-7 indicates Monday to Sunday.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + }, + }, + "url_notices": { + Type: schema.TypeList, + Optional: true, + Description: "The maximum number of callback notifications is 3.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Required: true, + Description: "Callback URL (limited to 256 characters).", + }, + "start_time": { + Type: schema.TypeInt, + Optional: true, + Description: "Notification Start Time Number of seconds at the start of a day.", + }, + "end_time": { + Type: schema.TypeInt, + Optional: true, + Description: "Notification End Time Seconds at the start of a day.", + }, + "weekday": { + Type: schema.TypeSet, + Optional: true, + Description: "Notification period 1-7 indicates Monday to Sunday.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + }, + }, + "cls_notices": { + Type: schema.TypeList, + Optional: true, + Description: "A maximum of one alarm notification can be pushed to the CLS service.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "region": { + Type: schema.TypeString, + Required: true, + Description: "Regional.", + }, + "log_set_id": { + Type: schema.TypeString, + Required: true, + Description: "Log collection Id.", + }, + "topic_id": { + Type: schema.TypeString, + Required: true, + Description: "Theme Id.", + }, + "enable": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "Start-stop status, can not be transmitted, default enabled. 0= Disabled, 1= enabled.", + }, + }, + }, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + Description: "Last Modified By.", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Last modified time.", + }, + "is_preset": { + Type: schema.TypeInt, + Computed: true, + Description: "Whether it is the system default notification template 0=No 1=Yes.", + }, + "policy_ids": { + Type: schema.TypeSet, + Computed: true, + Description: "List of alarm policy IDs bound to the alarm notification template.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + } +} + +func resourceTencentMonitorAlarmNoticeCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_monitor_alarm_notice.create")() + + var ( + monitorService = MonitorService{client: meta.(*TencentCloudClient).apiV3Conn} + request = monitor.NewCreateAlarmNoticeRequest() + ) + request.Module = helper.String("monitor") + request.Name = helper.String(d.Get("name").(string)) + request.NoticeType = helper.String(d.Get("notice_type").(string)) + request.NoticeLanguage = helper.String(d.Get("notice_language").(string)) + + if v, ok := d.GetOk("user_notices"); ok { + userNotices := make([]*monitor.UserNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + userNotice := monitor.UserNotice{} + userNotice.ReceiverType = helper.String(m["receiver_type"].(string)) + userNotice.StartTime = helper.IntInt64(m["start_time"].(int)) + userNotice.EndTime = helper.IntInt64(m["end_time"].(int)) + + if v, ok := m["notice_way"]; ok { + noticeWay := v.(*schema.Set).List() + noticeWayArr := make([]*string, 0, len(noticeWay)) + for _, noticeId := range noticeWay { + noticeWayArr = append(noticeWayArr, helper.String(noticeId.(string))) + } + userNotice.NoticeWay = noticeWayArr + } + + if v, ok := m["user_ids"]; ok { + userIds := v.(*schema.Set).List() + userIdsArr := make([]*int64, 0, len(userIds)) + for _, userId := range userIds { + userIdsArr = append(userIdsArr, helper.IntInt64(userId.(int))) + } + userNotice.UserIds = userIdsArr + } + + if v, ok := m["group_ids"]; ok { + groupIds := v.(*schema.Set).List() + groupIdsArr := make([]*int64, 0, len(groupIds)) + for _, groupId := range groupIds { + groupIdsArr = append(groupIdsArr, helper.IntInt64(groupId.(int))) + } + userNotice.GroupIds = groupIdsArr + } + + if v, ok := m["phone_order"]; ok { + phoneOrder := v.(*schema.Set).List() + phoneOrderArr := make([]*int64, 0, len(phoneOrder)) + for _, phone := range phoneOrder { + phoneOrderArr = append(phoneOrderArr, helper.IntInt64(phone.(int))) + } + userNotice.PhoneOrder = phoneOrderArr + } + + if m["phone_circle_times"] != nil { + userNotice.PhoneCircleTimes = helper.IntInt64(m["phone_circle_times"].(int)) + } + + if m["phone_inner_interval"] != nil { + userNotice.PhoneInnerInterval = helper.IntInt64(m["phone_inner_interval"].(int)) + } + + if m["phone_circle_interval"] != nil { + userNotice.PhoneCircleInterval = helper.IntInt64(m["phone_circle_interval"].(int)) + } + + if m["need_phone_arrive_notice"] != nil { + userNotice.NeedPhoneArriveNotice = helper.IntInt64(m["need_phone_arrive_notice"].(int)) + } + + if m["phone_call_type"] != nil { + userNotice.PhoneCallType = helper.String(m["phone_call_type"].(string)) + } + + if v, ok := m["weekday"]; ok { + weekday := v.(*schema.Set).List() + weekdayArr := make([]*int64, 0, len(weekday)) + for _, week := range weekday { + weekdayArr = append(weekdayArr, helper.IntInt64(week.(int))) + } + userNotice.Weekday = weekdayArr + } + userNotices = append(userNotices, &userNotice) + } + request.UserNotices = userNotices + } + + if v, ok := d.GetOk("url_notices"); ok { + urlNotices := make([]*monitor.URLNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + urlNotice := monitor.URLNotice{} + urlNotice.URL = helper.String(m["url"].(string)) + + if m["start_time"] != nil { + urlNotice.StartTime = helper.IntInt64(m["start_time"].(int)) + } + + if m["end_time"] != nil { + urlNotice.EndTime = helper.IntInt64(m["end_time"].(int)) + } + + if v, ok := m["weekday"]; ok { + weekday := v.(*schema.Set).List() + weekdayArr := make([]*int64, 0, len(weekday)) + for _, week := range weekday { + weekdayArr = append(weekdayArr, helper.IntInt64(week.(int))) + } + urlNotice.Weekday = weekdayArr + } + urlNotices = append(urlNotices, &urlNotice) + } + request.URLNotices = urlNotices + } + + if v, ok := d.GetOk("cls_notices"); ok { + clsNotices := make([]*monitor.CLSNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + clsNotice := monitor.CLSNotice{} + clsNotice.Region = helper.String(m["region"].(string)) + clsNotice.LogSetId = helper.String(m["log_set_id"].(string)) + clsNotice.TopicId = helper.String(m["topic_id"].(string)) + + if m["enable"] != nil { + clsNotice.Enable = helper.IntInt64(m["enable"].(int)) + } + clsNotices = append(clsNotices, &clsNotice) + } + request.CLSNotices = clsNotices + } + + var noticeId *string + if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + ratelimit.Check(request.GetAction()) + response, err := monitorService.client.UseMonitorClient().CreateAlarmNotice(request) + if err != nil { + return retryError(err, InternalError) + } + noticeId = response.Response.NoticeId + return nil + }); err != nil { + return err + } + + d.SetId(*noticeId) + + return resourceTencentMonitorAlarmNoticeRead(d, meta) +} + +func resourceTencentMonitorAlarmNoticeRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_monitor_alarm_notice.read")() + + var ( + monitorService = MonitorService{client: meta.(*TencentCloudClient).apiV3Conn} + err error + alarmNotice []*monitor.AlarmNotice + ) + + alarmNoticeMap := make(map[string]interface{}) + alarmNoticeMap["order"] = helper.String("ASC") + var tmpAlarmNotice = []*string{helper.String(d.Id())} + alarmNoticeMap["noticeArr"] = tmpAlarmNotice + + alarmNotice, err = monitorService.DescribeAlarmNoticeById(nil, alarmNoticeMap) + if err != nil { + return err + } + for _, noticesItem := range alarmNotice { + if err = d.Set("name", noticesItem.Name); err != nil { + return err + } + if err = d.Set("notice_type", noticesItem.NoticeType); err != nil { + return err + } + if err = d.Set("notice_language", noticesItem.NoticeLanguage); err != nil { + return err + } + if err = d.Set("updated_by", noticesItem.UpdatedBy); err != nil { + return err + } + if err = d.Set("updated_at", noticesItem.UpdatedAt); err != nil { + return err + } + if err = d.Set("is_preset", noticesItem.IsPreset); err != nil { + return err + } + if err = d.Set("policy_ids", noticesItem.PolicyIds); err != nil { + return err + } + + userNoticesItems := make([]interface{}, 0, 100) + for _, userNotices := range noticesItem.UserNotices { + userNoticesItems = append(userNoticesItems, map[string]interface{}{ + "receiver_type": userNotices.ReceiverType, + "start_time": userNotices.StartTime, + "end_time": userNotices.EndTime, + "notice_way": userNotices.NoticeWay, + "user_ids": userNotices.UserIds, + "group_ids": userNotices.GroupIds, + "phone_order": userNotices.PhoneOrder, + "phone_circle_times": userNotices.PhoneCircleTimes, + "phone_inner_interval": userNotices.PhoneInnerInterval, + "phone_circle_interval": userNotices.PhoneCircleInterval, + "need_phone_arrive_notice": userNotices.NeedPhoneArriveNotice, + "phone_call_type": userNotices.PhoneCallType, + "weekday": userNotices.Weekday, + }) + } + + urlNoticesItems := make([]interface{}, 0, 100) + for _, urlNotice := range noticesItem.URLNotices { + urlNoticesItems = append(urlNoticesItems, map[string]interface{}{ + "url": urlNotice.URL, + "start_time": urlNotice.StartTime, + "end_time": urlNotice.EndTime, + "weekday": urlNotice.Weekday, + }) + } + + clsNoticesItems := make([]interface{}, 0, 100) + for _, clsNotice := range noticesItem.CLSNotices { + clsNoticesItems = append(clsNoticesItems, map[string]interface{}{ + "region": clsNotice.Region, + "log_set_id": clsNotice.LogSetId, + "topic_id": clsNotice.TopicId, + "enable": clsNotice.Enable, + }) + } + + if err = d.Set("user_notices", userNoticesItems); err != nil { + return err + } + if err = d.Set("url_notices", urlNoticesItems); err != nil { + return err + } + if err = d.Set("cls_notices", clsNoticesItems); err != nil { + return err + } + + } + + return nil +} + +func resourceTencentMonitorAlarmNoticeUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_monitor_alarm_notice.update")() + + var ( + monitorService = MonitorService{client: meta.(*TencentCloudClient).apiV3Conn} + request = monitor.NewModifyAlarmNoticeRequest() + ) + + request.Module = helper.String("monitor") + request.Name = helper.String(d.Get("name").(string)) + request.NoticeType = helper.String(d.Get("notice_type").(string)) + request.NoticeLanguage = helper.String(d.Get("notice_language").(string)) + request.NoticeId = helper.String(d.Id()) + + if v, ok := d.GetOk("user_notices"); ok { + userNotices := make([]*monitor.UserNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + userNotice := monitor.UserNotice{} + userNotice.ReceiverType = helper.String(m["receiver_type"].(string)) + userNotice.StartTime = helper.IntInt64(m["start_time"].(int)) + userNotice.EndTime = helper.IntInt64(m["end_time"].(int)) + + if v, ok := m["notice_way"]; ok { + noticeWay := v.(*schema.Set).List() + noticeWayArr := make([]*string, 0, len(noticeWay)) + for _, noticeId := range noticeWay { + noticeWayArr = append(noticeWayArr, helper.String(noticeId.(string))) + } + userNotice.NoticeWay = noticeWayArr + } + + if v, ok := m["user_ids"]; ok { + userIds := v.(*schema.Set).List() + userIdsArr := make([]*int64, 0, len(userIds)) + for _, userId := range userIds { + userIdsArr = append(userIdsArr, helper.IntInt64(userId.(int))) + } + userNotice.UserIds = userIdsArr + } + + if v, ok := m["group_ids"]; ok { + groupIds := v.(*schema.Set).List() + groupIdsArr := make([]*int64, 0, len(groupIds)) + for _, groupId := range groupIds { + groupIdsArr = append(groupIdsArr, helper.IntInt64(groupId.(int))) + } + userNotice.GroupIds = groupIdsArr + } + + if v, ok := m["phone_order"]; ok { + phoneOrder := v.(*schema.Set).List() + phoneOrderArr := make([]*int64, 0, len(phoneOrder)) + for _, phone := range phoneOrder { + phoneOrderArr = append(phoneOrderArr, helper.IntInt64(phone.(int))) + } + userNotice.PhoneOrder = phoneOrderArr + } + + if m["phone_circle_times"] != nil { + userNotice.PhoneCircleTimes = helper.IntInt64(m["phone_circle_times"].(int)) + } + + if m["phone_inner_interval"] != nil { + userNotice.PhoneInnerInterval = helper.IntInt64(m["phone_inner_interval"].(int)) + } + + if m["phone_circle_interval"] != nil { + userNotice.PhoneCircleInterval = helper.IntInt64(m["phone_circle_interval"].(int)) + } + + if m["need_phone_arrive_notice"] != nil { + userNotice.NeedPhoneArriveNotice = helper.IntInt64(m["need_phone_arrive_notice"].(int)) + } + + if m["phone_call_type"] != nil { + userNotice.PhoneCallType = helper.String(m["phone_call_type"].(string)) + } + + if v, ok := m["weekday"]; ok { + weekday := v.(*schema.Set).List() + weekdayArr := make([]*int64, 0, len(weekday)) + for _, week := range weekday { + weekdayArr = append(weekdayArr, helper.IntInt64(week.(int))) + } + userNotice.Weekday = weekdayArr + } + userNotices = append(userNotices, &userNotice) + } + request.UserNotices = userNotices + } + + if v, ok := d.GetOk("url_notices"); ok { + urlNotices := make([]*monitor.URLNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + urlNotice := monitor.URLNotice{} + urlNotice.URL = helper.String(m["url"].(string)) + + if m["start_time"] != nil { + urlNotice.StartTime = helper.IntInt64(m["start_time"].(int)) + } + + if m["end_time"] != nil { + urlNotice.EndTime = helper.IntInt64(m["end_time"].(int)) + } + + if v, ok := m["weekday"]; ok { + weekday := v.(*schema.Set).List() + weekdayArr := make([]*int64, 0, len(weekday)) + for _, week := range weekday { + weekdayArr = append(weekdayArr, helper.IntInt64(week.(int))) + } + urlNotice.Weekday = weekdayArr + } + urlNotices = append(urlNotices, &urlNotice) + } + request.URLNotices = urlNotices + } + + if v, ok := d.GetOk("cls_notices"); ok { + clsNotices := make([]*monitor.CLSNotice, 0, 10) + for _, item := range v.([]interface{}) { + m := item.(map[string]interface{}) + clsNotice := monitor.CLSNotice{} + clsNotice.Region = helper.String(m["region"].(string)) + clsNotice.LogSetId = helper.String(m["log_set_id"].(string)) + clsNotice.TopicId = helper.String(m["topic_id"].(string)) + + if m["enable"] != nil { + clsNotice.Enable = helper.IntInt64(m["enable"].(int)) + } + clsNotices = append(clsNotices, &clsNotice) + } + request.CLSNotices = clsNotices + } + + if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + ratelimit.Check(request.GetAction()) + _, err := monitorService.client.UseMonitorClient().ModifyAlarmNotice(request) + if err != nil { + return retryError(err, InternalError) + } + return nil + }); err != nil { + return err + } + + d.SetId(d.Id()) + + return resourceTencentMonitorAlarmNoticeRead(d, meta) +} + +func resourceTencentMonitorAlarmNoticeDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_monitor_alarm_notice.delete")() + + var ( + monitorService = MonitorService{client: meta.(*TencentCloudClient).apiV3Conn} + ) + + err := monitorService.DeleteMonitorAlarmNoticeById(nil, d.Id()) + if err != nil { + return err + } + return nil +} diff --git a/tencentcloud/resource_tc_monitor_alarm_notice_test.go b/tencentcloud/resource_tc_monitor_alarm_notice_test.go new file mode 100644 index 0000000000..cd4b8cbbe0 --- /dev/null +++ b/tencentcloud/resource_tc_monitor_alarm_notice_test.go @@ -0,0 +1,58 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +func TestAccTencentCloudMonitorAlarmNoticeResource(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMonitorAlarmNotice, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "name", "test_alarm_notice_1"), + resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "notice_type", "ALL"), + resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "notice_language", "zh-CN"), + resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "is_preset", "0"), + ), + }, + }, + }) +} + +const testAccMonitorAlarmNotice string = ` +resource "tencentcloud_monitor_alarm_notice" "example" { + name = "test_alarm_notice_1" + notice_type = "ALL" + notice_language = "zh-CN" + + user_notices { + receiver_type = "USER" + start_time = 0 + end_time = 1 + notice_way = ["SMS","EMAIL"] + user_ids = [10001] + group_ids = [] + phone_order = [10001] + phone_circle_times = 2 + phone_circle_interval = 50 + phone_inner_interval = 60 + need_phone_arrive_notice = 1 + phone_call_type = "CIRCLE" + weekday =[1,2,3,4,5,6,7] + } + + url_notices { + url = "https://www.mytest.com/validate" + end_time = 0 + start_time = 1 + weekday = [1,2,3,4,5,6,7] + } + +} +` diff --git a/tencentcloud/service_tencentcloud_monitor.go b/tencentcloud/service_tencentcloud_monitor.go index f12f6a0bb6..b96e71af81 100644 --- a/tencentcloud/service_tencentcloud_monitor.go +++ b/tencentcloud/service_tencentcloud_monitor.go @@ -138,6 +138,49 @@ func (me *MonitorService) DescribeAlarmPolicyById(ctx context.Context, policyId return } +func (me *MonitorService) DescribeAlarmNoticeById(ctx context.Context, alarmmap map[string]interface{}) (noticeIds []*monitor.AlarmNotice, errRet error) { + var ( + request = monitor.NewDescribeAlarmNoticesRequest() + response *monitor.DescribeAlarmNoticesResponse + err error + ) + request.Module = helper.String("monitor") + request.PageNumber = helper.IntInt64(1) + request.PageSize = helper.IntInt64(200) + request.Order = alarmmap["order"].(*string) + if v, ok := alarmmap["ownerUid"]; ok { + request.OwnerUid = v.(*int64) + } + if v, ok := alarmmap["name"]; ok { + request.Name = v.(*string) + } + if v, ok := alarmmap["receiver_type"]; ok { + request.ReceiverType = v.(*string) + } + + if v, ok := alarmmap["userIdArr"]; ok { + request.UserIds = v.([]*int64) + } + if v, ok := alarmmap["groupArr"]; ok { + request.GroupIds = v.([]*int64) + } + if v, ok := alarmmap["noticeArr"]; ok { + request.NoticeIds = v.([]*string) + } + + if err = resource.Retry(readRetryTimeout, func() *resource.RetryError { + ratelimit.Check(request.GetAction()) + if response, err = me.client.UseMonitorClient().DescribeAlarmNotices(request); err != nil { + return retryError(err, InternalError) + } + noticeIds = response.Response.Notices + return nil + }); err != nil { + return + } + return +} + func (me *MonitorService) DescribePolicyGroup(ctx context.Context, groupId int64) (info *monitor.DescribePolicyGroupListGroup, errRet error) { var ( @@ -441,6 +484,26 @@ func (me *MonitorService) DeleteMonitorTmpScrapeJobById(ctx context.Context, tmp return } +func (me *MonitorService) DeleteMonitorAlarmNoticeById(ctx context.Context, Id string) (errRet error) { + request := monitor.NewDeleteAlarmNoticesRequest() + request.Module = helper.String("monitor") + noticeId := Id + var n = []*string{¬iceId} + request.NoticeIds = n + + if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + ratelimit.Check(request.GetAction()) + _, err := me.client.UseMonitorClient().DeleteAlarmNotices(request) + if err != nil { + return retryError(err, InternalError) + } + return nil + }); err != nil { + return err + } + return +} + func (me *MonitorService) DescribeMonitorTmpExporterIntegration(ctx context.Context, tmpExporterIntegrationId string) (tmpExporterIntegration *monitor.IntegrationConfiguration, errRet error) { var ( logId = getLogId(ctx) diff --git a/website/docs/d/monitor_alarm_notices.html.markdown b/website/docs/d/monitor_alarm_notices.html.markdown new file mode 100644 index 0000000000..d9e49ae1b6 --- /dev/null +++ b/website/docs/d/monitor_alarm_notices.html.markdown @@ -0,0 +1,79 @@ +--- +subcategory: "Monitor" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_monitor_alarm_notices" +sidebar_current: "docs-tencentcloud-datasource-monitor_alarm_notices" +description: |- + Use this data source to Interlude notification list. +--- + +# tencentcloud_monitor_alarm_notices + +Use this data source to Interlude notification list. + +## Example Usage + +```hcl +data "tencentcloud_monitor_alarm_notices" "notices" { + order = "DESC" + owner_uid = 1 + name = "" + receiver_type = "" + user_ids = [] + group_ids = [] + notice_ids = [] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `group_ids` - (Optional, Set: [`Int`]) Receive group list. +* `name` - (Optional, String) Alarm notification template name Used for fuzzy search. +* `notice_ids` - (Optional, Set: [`String`]) Receive group list. +* `order` - (Optional, String) Sort by update time ASC=forward order DESC=reverse order. +* `owner_uid` - (Optional, Int) The primary account uid is used to create a preset notification. +* `receiver_type` - (Optional, String) To filter alarm notification templates according to recipients, you need to select the notification user type. USER=user GROUP=user group Leave blank = not filter by recipient. +* `result_output_file` - (Optional, String) Used to store results. +* `user_ids` - (Optional, Set: [`Int`]) List of recipients. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `alarm_notice` - Alarm notification template list. + * `cls_notices` - A maximum of one alarm notification can be pushed to the CLS service. + * `enable` - Start-stop status, can not be transmitted, default enabled. 0= Disabled, 1= enabled. + * `log_set_id` - Log collection Id. + * `region` - Regional. + * `topic_id` - Theme Id. + * `id` - Alarm notification template ID. + * `is_preset` - Whether it is the system default notification template 0=No 1=Yes. + * `name` - Alarm notification template name. + * `notice_language` - Notification language zh-CN=Chinese en-US=English. + * `notice_type` - Alarm notification type ALARM=Notification not restored OK=Notification restored ALL. + * `policy_ids` - List of alarm policy IDs bound to the alarm notification template. + * `updated_at` - Last modified time. + * `updated_by` - Last Modified By. + * `url_notices` - The maximum number of callback notifications is 3. + * `end_time` - Notification End Time Seconds at the start of a day. + * `start_time` - Notification Start Time Number of seconds at the start of a day. + * `url` - Callback URL (limited to 256 characters). + * `weekday` - Notification period 1-7 indicates Monday to Sunday. + * `user_notices` - Alarm notification template list.(At most five). + * `end_time` - The number of seconds since the notification end time 00:00:00 (value range 0-86399). + * `group_ids` - User group ID list. + * `need_phone_arrive_notice` - Contact notification required 0= No 1= Yes. + * `notice_way` - Notification Channel List EMAIL=Mail SMS=SMS CALL=Telephone WECHAT=WeChat RTX=Enterprise WeChat. + * `phone_call_type` - Call type SYNC= Simultaneous call CIRCLE= Round call If this parameter is not specified, the default value is round call. + * `phone_circle_interval` - Number of seconds between polls (value range: 60-900). + * `phone_circle_times` - Number of telephone polls (value range: 1-5). + * `phone_inner_interval` - Number of seconds between calls in a polling session (value range: 60-900). + * `phone_order` - Telephone polling list. + * `receiver_type` - Recipient Type USER=User GROUP=User Group. + * `start_time` - The number of seconds since the notification start time 00:00:00 (value range 0-86399). + * `user_ids` - User UID List. + * `weekday` - Notification period 1-7 indicates Monday to Sunday. + + diff --git a/website/docs/r/monitor_alarm_notice.html.markdown b/website/docs/r/monitor_alarm_notice.html.markdown new file mode 100644 index 0000000000..4175c91f15 --- /dev/null +++ b/website/docs/r/monitor_alarm_notice.html.markdown @@ -0,0 +1,107 @@ +--- +subcategory: "Monitor" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_monitor_alarm_notice" +sidebar_current: "docs-tencentcloud-resource-monitor_alarm_notice" +description: |- + Provides a alarm notice resource for monitor. +--- + +# tencentcloud_monitor_alarm_notice + +Provides a alarm notice resource for monitor. + +## Example Usage + +```hcl +resource "tencentcloud_monitor_alarm_notice" "example" { + name = "test_alarm_notice_1" + notice_type = "ALL" + notice_language = "zh-CN" + + user_notices { + receiver_type = "USER" + start_time = 0 + end_time = 1 + notice_way = ["SMS", "EMAIL"] + user_ids = [10001] + group_ids = [] + phone_order = [10001] + phone_circle_times = 2 + phone_circle_interval = 50 + phone_inner_interval = 60 + need_phone_arrive_notice = 1 + phone_call_type = "CIRCLE" + weekday = [1, 2, 3, 4, 5, 6, 7] + } + + url_notices { + url = "https://www.mytest.com/validate" + end_time = 0 + start_time = 1 + weekday = [1, 2, 3, 4, 5, 6, 7] + } + +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required, String) Notification template name within 60. +* `notice_language` - (Required, String) Notification language zh-CN=Chinese en-US=English. +* `notice_type` - (Required, String) Alarm notification type ALARM=Notification not restored OK=Notification restored ALL. +* `cls_notices` - (Optional, List) A maximum of one alarm notification can be pushed to the CLS service. +* `url_notices` - (Optional, List) The maximum number of callback notifications is 3. +* `user_notices` - (Optional, List) Alarm notification template list.(At most five). + +The `cls_notices` object supports the following: + +* `log_set_id` - (Required, String) Log collection Id. +* `region` - (Required, String) Regional. +* `topic_id` - (Required, String) Theme Id. +* `enable` - (Optional, Int) Start-stop status, can not be transmitted, default enabled. 0= Disabled, 1= enabled. + +The `url_notices` object supports the following: + +* `url` - (Required, String) Callback URL (limited to 256 characters). +* `end_time` - (Optional, Int) Notification End Time Seconds at the start of a day. +* `start_time` - (Optional, Int) Notification Start Time Number of seconds at the start of a day. +* `weekday` - (Optional, Set) Notification period 1-7 indicates Monday to Sunday. + +The `user_notices` object supports the following: + +* `end_time` - (Required, Int) The number of seconds since the notification end time 00:00:00 (value range 0-86399). +* `notice_way` - (Required, Set) Notification Channel List EMAIL=Mail SMS=SMS CALL=Telephone WECHAT=WeChat RTX=Enterprise WeChat. +* `receiver_type` - (Required, String) Recipient Type USER=User GROUP=User Group. +* `start_time` - (Required, Int) The number of seconds since the notification start time 00:00:00 (value range 0-86399). +* `group_ids` - (Optional, Set) User group ID list. +* `need_phone_arrive_notice` - (Optional, Int) Contact notification required 0= No 1= Yes. +* `phone_call_type` - (Optional, String) Call type SYNC= Simultaneous call CIRCLE= Round call If this parameter is not specified, the default value is round call. +* `phone_circle_interval` - (Optional, Int) Number of seconds between polls (value range: 60-900). +* `phone_circle_times` - (Optional, Int) Number of telephone polls (value range: 1-5). +* `phone_inner_interval` - (Optional, Int) Number of seconds between calls in a polling session (value range: 60-900). +* `phone_order` - (Optional, Set) Telephone polling list. +* `user_ids` - (Optional, Set) User UID List. +* `weekday` - (Optional, Set) Notification period 1-7 indicates Monday to Sunday. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `is_preset` - Whether it is the system default notification template 0=No 1=Yes. +* `policy_ids` - List of alarm policy IDs bound to the alarm notification template. +* `updated_at` - Last modified time. +* `updated_by` - Last Modified By. + + +## Import + +Monitor Alarm Notice can be imported, e.g. + +``` +$ terraform import tencentcloud_monitor_alarm_notice.import-test noticeId +``` + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index 1a10275836..1303150683 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -1089,6 +1089,9 @@
  • Data Sources