Skip to content

Commit a4c4b79

Browse files
samcrangstack72
authored andcommitted
Add support for StatusCake confirmation servers (hashicorp#11179)
* Add support for StatusCake confirmation servers * Add documentation for new StatusCake confirmations argument
1 parent bad2000 commit a4c4b79

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

builtin/providers/statuscake/resource_statuscaketest.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func resourceStatusCakeTest() *schema.Resource {
5757
Type: schema.TypeInt,
5858
Optional: true,
5959
},
60+
"confirmations": &schema.Schema{
61+
Type: schema.TypeInt,
62+
Optional: true,
63+
},
6064
},
6165
}
6266
}
@@ -65,13 +69,14 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
6569
client := meta.(*statuscake.Client)
6670

6771
newTest := &statuscake.Test{
68-
WebsiteName: d.Get("website_name").(string),
69-
WebsiteURL: d.Get("website_url").(string),
70-
CheckRate: d.Get("check_rate").(int),
71-
TestType: d.Get("test_type").(string),
72-
Paused: d.Get("paused").(bool),
73-
Timeout: d.Get("timeout").(int),
74-
ContactID: d.Get("contact_id").(int),
72+
WebsiteName: d.Get("website_name").(string),
73+
WebsiteURL: d.Get("website_url").(string),
74+
CheckRate: d.Get("check_rate").(int),
75+
TestType: d.Get("test_type").(string),
76+
Paused: d.Get("paused").(bool),
77+
Timeout: d.Get("timeout").(int),
78+
ContactID: d.Get("contact_id").(int),
79+
Confirmation: d.Get("confirmations").(int),
7580
}
7681

7782
log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -134,6 +139,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
134139
d.Set("paused", testResp.Paused)
135140
d.Set("timeout", testResp.Timeout)
136141
d.Set("contact_id", testResp.ContactID)
142+
d.Set("confirmations", testResp.Confirmation)
137143

138144
return nil
139145
}
@@ -167,5 +173,8 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
167173
if v, ok := d.GetOk("contact_id"); ok {
168174
test.ContactID = v.(int)
169175
}
176+
if v, ok := d.GetOk("confirmations"); ok {
177+
test.Confirmation = v.(int)
178+
}
170179
return test
171180
}

builtin/providers/statuscake/resource_statuscaketest_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
5252
resource.TestCheckResourceAttr("statuscake_test.google", "check_rate", "500"),
5353
resource.TestCheckResourceAttr("statuscake_test.google", "paused", "true"),
5454
resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
55+
resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
5556
),
5657
},
5758
},
@@ -116,6 +117,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
116117
err = check(key, value, strconv.Itoa(test.Timeout))
117118
case "contact_id":
118119
err = check(key, value, strconv.Itoa(test.ContactID))
120+
case "confirmations":
121+
err = check(key, value, strconv.Itoa(test.Confirmation))
119122
}
120123

121124
if err != nil {
@@ -145,6 +148,7 @@ resource "statuscake_test" "google" {
145148
test_type = "HTTP"
146149
check_rate = 300
147150
contact_id = 12345
151+
confirmations = 1
148152
}
149153
`
150154

website/source/docs/providers/statuscake/r/test.html.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ resource "statuscake_test" "google" {
2626
The following arguments are supported:
2727

2828
* `website_name` - (Required) This is the name of the test and the website to be monitored.
29-
* `website_url` - (Required) The URL of the website to be monitored
30-
* `check_rate` - (Optional) Test check rate in seconds. Defaults to 300
31-
* `test_type` - (Required) The type of Test. Either HTTP or TCP
29+
* `website_url` - (Required) The URL of the website to be monitored.
30+
* `check_rate` - (Optional) Test check rate in seconds. Defaults to 300.
31+
* `test_type` - (Required) The type of Test. Either HTTP or TCP.
3232
* `paused` - (Optional) Whether or not the test is paused. Defaults to false.
3333
* `timeout` - (Optional) The timeout of the test in seconds.
3434
* `contact_id` - (Optional) The ID of the contact group to associate with the test.
35+
* `confirmations` - (Optional) The number of confirmation servers to use in order to detect downtime. Defaults to 0.
3536

3637

3738
## Attributes Reference

0 commit comments

Comments
 (0)