Skip to content

Commit 99b7e69

Browse files
committed
add notice valid
1 parent e304803 commit 99b7e69

File tree

3 files changed

+171
-74
lines changed

3 files changed

+171
-74
lines changed

tencentcloud/resource_tc_monitor_alarm_notice.go

Lines changed: 79 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,56 @@ Provides a alarm notice resource for monitor.
44
Example Usage
55
66
```hcl
7-
resource "tencentcloud_monitor_alarm_notice" "foo" {
8-
name = "tf-alarm_notice"
9-
notice_type = "ALL"
10-
notice_language = "zh-CN"
11-
12-
user_notices {
13-
receiver_type = "USER"
14-
start_time = 0
15-
end_time = 1
16-
notice_way = ["SMS","EMAIL"]
17-
user_ids = [10001]
18-
group_ids = []
19-
phone_order = [10001]
20-
phone_circle_times = 2
21-
phone_circle_interval = 50
22-
phone_inner_interval = 60
23-
need_phone_arrive_notice = 1
24-
phone_call_type = "CIRCLE"
25-
weekday =[1,2,3,4,5,6,7]
26-
}
7+
resource "tencentcloud_monitor_alarm_notice" "example" {
8+
name = "test_alarm_notice"
9+
notice_language = "zh-CN"
10+
notice_type = "ALL"
2711
2812
url_notices {
29-
url = "https://www.mytest.com/validate"
30-
end_time = 0
31-
start_time = 1
32-
weekday = [1,2,3,4,5,6,7]
13+
end_time = 86399
14+
is_valid = 0
15+
start_time = 0
16+
url = "https://www.mytest.com/validate"
17+
weekday = [
18+
1,
19+
2,
20+
3,
21+
4,
22+
5,
23+
6,
24+
7,
25+
]
3326
}
3427
28+
user_notices {
29+
end_time = 86399
30+
group_ids = []
31+
need_phone_arrive_notice = 1
32+
notice_way = [
33+
"EMAIL",
34+
"SMS",
35+
]
36+
phone_call_type = "CIRCLE"
37+
phone_circle_interval = 180
38+
phone_circle_times = 2
39+
phone_inner_interval = 180
40+
phone_order = []
41+
receiver_type = "USER"
42+
start_time = 0
43+
user_ids = [
44+
11082189,
45+
11082190,
46+
]
47+
weekday = [
48+
1,
49+
2,
50+
3,
51+
4,
52+
5,
53+
6,
54+
7,
55+
]
56+
}
3557
}
3658
```
3759
@@ -171,6 +193,17 @@ func resourceTencentCloudMonitorAlarmNotice() *schema.Resource {
171193
Required: true,
172194
Description: "Callback URL (limited to 256 characters).",
173195
},
196+
"is_valid": {
197+
Type: schema.TypeInt,
198+
Optional: true,
199+
Computed: true,
200+
Description: "If passed verification `0` is no, `1` is yes. Default `0`.",
201+
},
202+
"validation_code": {
203+
Type: schema.TypeString,
204+
Optional: true,
205+
Description: "Verification code.",
206+
},
174207
"start_time": {
175208
Type: schema.TypeInt,
176209
Optional: true,
@@ -347,6 +380,14 @@ func resourceTencentMonitorAlarmNoticeCreate(d *schema.ResourceData, meta interf
347380
urlNotice := monitor.URLNotice{}
348381
urlNotice.URL = helper.String(m["url"].(string))
349382

383+
if m["is_valid"] != nil {
384+
urlNotice.IsValid = helper.IntInt64(m["is_valid"].(int))
385+
}
386+
387+
if m["validation_code"] != "" {
388+
urlNotice.ValidationCode = helper.String(m["validation_code"].(string))
389+
}
390+
350391
if m["start_time"] != nil {
351392
urlNotice.StartTime = helper.IntInt64(m["start_time"].(int))
352393
}
@@ -472,10 +513,12 @@ func resourceTencentMonitorAlarmNoticeRead(d *schema.ResourceData, meta interfac
472513
urlNoticesItems := make([]interface{}, 0, 100)
473514
for _, urlNotice := range noticesItem.URLNotices {
474515
urlNoticesItems = append(urlNoticesItems, map[string]interface{}{
475-
"url": urlNotice.URL,
476-
"start_time": urlNotice.StartTime,
477-
"end_time": urlNotice.EndTime,
478-
"weekday": urlNotice.Weekday,
516+
"url": urlNotice.URL,
517+
"is_valid": urlNotice.IsValid,
518+
"validation_code": urlNotice.ValidationCode,
519+
"start_time": urlNotice.StartTime,
520+
"end_time": urlNotice.EndTime,
521+
"weekday": urlNotice.Weekday,
479522
})
480523
}
481524

@@ -603,6 +646,14 @@ func resourceTencentMonitorAlarmNoticeUpdate(d *schema.ResourceData, meta interf
603646
urlNotice := monitor.URLNotice{}
604647
urlNotice.URL = helper.String(m["url"].(string))
605648

649+
if m["is_valid"] != nil {
650+
urlNotice.IsValid = helper.IntInt64(m["is_valid"].(int))
651+
}
652+
653+
if m["validation_code"] != "" {
654+
urlNotice.ValidationCode = helper.String(m["validation_code"].(string))
655+
}
656+
606657
if m["start_time"] != nil {
607658
urlNotice.StartTime = helper.IntInt64(m["start_time"].(int))
608659
}

tencentcloud/resource_tc_monitor_alarm_notice_test.go

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestAccTencentCloudMonitorAlarmNoticeResource(t *testing.T) {
1515
{
1616
Config: testAccMonitorAlarmNotice,
1717
Check: resource.ComposeTestCheckFunc(
18-
resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "name", "test_alarm_notice_1"),
18+
resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "name", "test_alarm_notice"),
1919
resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "notice_type", "ALL"),
2020
resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "notice_language", "zh-CN"),
2121
resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_notice.example", "is_preset", "0"),
@@ -27,32 +27,54 @@ func TestAccTencentCloudMonitorAlarmNoticeResource(t *testing.T) {
2727

2828
const testAccMonitorAlarmNotice string = `
2929
resource "tencentcloud_monitor_alarm_notice" "example" {
30-
name = "test_alarm_notice_1"
31-
notice_type = "ALL"
32-
notice_language = "zh-CN"
33-
34-
user_notices {
35-
receiver_type = "USER"
36-
start_time = 0
37-
end_time = 1
38-
notice_way = ["SMS","EMAIL"]
39-
user_ids = [10001]
40-
group_ids = []
41-
phone_order = [10001]
42-
phone_circle_times = 2
43-
phone_circle_interval = 50
44-
phone_inner_interval = 60
45-
need_phone_arrive_notice = 1
46-
phone_call_type = "CIRCLE"
47-
weekday =[1,2,3,4,5,6,7]
48-
}
30+
name = "test_alarm_notice"
31+
notice_language = "zh-CN"
32+
notice_type = "ALL"
4933
5034
url_notices {
51-
url = "https://www.mytest.com/validate"
52-
end_time = 0
53-
start_time = 1
54-
weekday = [1,2,3,4,5,6,7]
35+
end_time = 86399
36+
is_valid = 0
37+
start_time = 0
38+
url = "https://www.mytest.com/validate"
39+
weekday = [
40+
1,
41+
2,
42+
3,
43+
4,
44+
5,
45+
6,
46+
7,
47+
]
5548
}
5649
50+
user_notices {
51+
end_time = 86399
52+
group_ids = []
53+
need_phone_arrive_notice = 1
54+
notice_way = [
55+
"EMAIL",
56+
"SMS",
57+
]
58+
phone_call_type = "CIRCLE"
59+
phone_circle_interval = 180
60+
phone_circle_times = 2
61+
phone_inner_interval = 180
62+
phone_order = []
63+
receiver_type = "USER"
64+
start_time = 0
65+
user_ids = [
66+
11082189,
67+
11082190,
68+
]
69+
weekday = [
70+
1,
71+
2,
72+
3,
73+
4,
74+
5,
75+
6,
76+
7,
77+
]
78+
}
5779
}
5880
`

website/docs/r/monitor_alarm_notice.html.markdown

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,56 @@ Provides a alarm notice resource for monitor.
1414
## Example Usage
1515

1616
```hcl
17-
resource "tencentcloud_monitor_alarm_notice" "foo" {
18-
name = "tf-alarm_notice"
19-
notice_type = "ALL"
17+
resource "tencentcloud_monitor_alarm_notice" "example" {
18+
name = "test_alarm_notice"
2019
notice_language = "zh-CN"
21-
22-
user_notices {
23-
receiver_type = "USER"
24-
start_time = 0
25-
end_time = 1
26-
notice_way = ["SMS", "EMAIL"]
27-
user_ids = [10001]
28-
group_ids = []
29-
phone_order = [10001]
30-
phone_circle_times = 2
31-
phone_circle_interval = 50
32-
phone_inner_interval = 60
33-
need_phone_arrive_notice = 1
34-
phone_call_type = "CIRCLE"
35-
weekday = [1, 2, 3, 4, 5, 6, 7]
36-
}
20+
notice_type = "ALL"
3721
3822
url_notices {
23+
end_time = 86399
24+
is_valid = 0
25+
start_time = 0
3926
url = "https://www.mytest.com/validate"
40-
end_time = 0
41-
start_time = 1
42-
weekday = [1, 2, 3, 4, 5, 6, 7]
27+
weekday = [
28+
1,
29+
2,
30+
3,
31+
4,
32+
5,
33+
6,
34+
7,
35+
]
4336
}
4437
38+
user_notices {
39+
end_time = 86399
40+
group_ids = []
41+
need_phone_arrive_notice = 1
42+
notice_way = [
43+
"EMAIL",
44+
"SMS",
45+
]
46+
phone_call_type = "CIRCLE"
47+
phone_circle_interval = 180
48+
phone_circle_times = 2
49+
phone_inner_interval = 180
50+
phone_order = []
51+
receiver_type = "USER"
52+
start_time = 0
53+
user_ids = [
54+
11082189,
55+
11082190,
56+
]
57+
weekday = [
58+
1,
59+
2,
60+
3,
61+
4,
62+
5,
63+
6,
64+
7,
65+
]
66+
}
4567
}
4668
```
4769

@@ -67,7 +89,9 @@ The `url_notices` object supports the following:
6789

6890
* `url` - (Required, String) Callback URL (limited to 256 characters).
6991
* `end_time` - (Optional, Int) Notification End Time Seconds at the start of a day.
92+
* `is_valid` - (Optional, Int) If passed verification `0` is no, `1` is yes. Default `0`.
7093
* `start_time` - (Optional, Int) Notification Start Time Number of seconds at the start of a day.
94+
* `validation_code` - (Optional, String) Verification code.
7195
* `weekday` - (Optional, Set) Notification period 1-7 indicates Monday to Sunday.
7296

7397
The `user_notices` object supports the following:

0 commit comments

Comments
 (0)