From 0e962b8ebd36cbb0e2f722a1859594b748713d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Gonc=CC=A7alves?= Date: Tue, 4 Apr 2017 16:58:11 +0100 Subject: Add support for StatusCake trigger rate --- resource_statuscaketest.go | 11 +++++++++++ resource_statuscaketest_test.go | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/resource_statuscaketest.go b/resource_statuscaketest.go index 4912758..101ee83 100644 --- a/resource_statuscaketest.go +++ b/resource_statuscaketest.go @@ -70,6 +70,12 @@ func resourceStatusCakeTest() *schema.Resource { Type: schema.TypeInt, Optional: true, }, + + "trigger_rate": { + Type: schema.TypeInt, + Optional: true, + Default: 5, + }, }, } } @@ -87,6 +93,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error { ContactID: d.Get("contact_id").(int), Confirmation: d.Get("confirmations").(int), Port: d.Get("port").(int), + TriggerRate: d.Get("trigger_rate").(int), } log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string)) @@ -151,6 +158,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error { d.Set("contact_id", testResp.ContactID) d.Set("confirmations", testResp.Confirmation) d.Set("port", testResp.Port) + d.Set("trigger_rate", testResp.TriggerRate) return nil } @@ -193,6 +201,9 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test { if v, ok := d.GetOk("port"); ok { test.Port = v.(int) } + if v, ok := d.GetOk("trigger_rate"); ok { + test.TriggerRate = v.(int) + } defaultStatusCodes := "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " + "408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " + diff --git a/resource_statuscaketest_test.go b/resource_statuscaketest_test.go index d38dc1c..f07fcc5 100644 --- a/resource_statuscaketest_test.go +++ b/resource_statuscaketest_test.go @@ -73,6 +73,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) { resource.TestCheckResourceAttr("statuscake_test.google", "timeout", "40"), resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"), resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"), + resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"), ), }, }, @@ -139,6 +140,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC err = check(key, value, strconv.Itoa(test.ContactID)) case "confirmations": err = check(key, value, strconv.Itoa(test.Confirmation)) + case "trigger_rate": + err = check(key, value, strconv.Itoa(test.TriggerRate)) } if err != nil { @@ -170,6 +173,7 @@ resource "statuscake_test" "google" { timeout = 10 contact_id = 43402 confirmations = 1 + trigger_rate = 10 } ` @@ -180,6 +184,7 @@ resource "statuscake_test" "google" { test_type = "HTTP" check_rate = 500 paused = true + trigger_rate = 20 } ` -- cgit v1.2.3