From b581540543290cbcd9b0e07ef93fec8b1d24b5c2 Mon Sep 17 00:00:00 2001 From: Sam Crang Date: Fri, 13 Jan 2017 11:35:15 +0000 Subject: Add support for StatusCake confirmation servers (#11179) * Add support for StatusCake confirmation servers * Add documentation for new StatusCake confirmations argument --- resource_statuscaketest.go | 23 ++++++++++++++++------- resource_statuscaketest_test.go | 4 ++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/resource_statuscaketest.go b/resource_statuscaketest.go index 08ace97..6c340d8 100644 --- a/resource_statuscaketest.go +++ b/resource_statuscaketest.go @@ -57,6 +57,10 @@ func resourceStatusCakeTest() *schema.Resource { Type: schema.TypeInt, Optional: true, }, + "confirmations": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, }, } } @@ -65,13 +69,14 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error { client := meta.(*statuscake.Client) newTest := &statuscake.Test{ - WebsiteName: d.Get("website_name").(string), - WebsiteURL: d.Get("website_url").(string), - CheckRate: d.Get("check_rate").(int), - TestType: d.Get("test_type").(string), - Paused: d.Get("paused").(bool), - Timeout: d.Get("timeout").(int), - ContactID: d.Get("contact_id").(int), + WebsiteName: d.Get("website_name").(string), + WebsiteURL: d.Get("website_url").(string), + CheckRate: d.Get("check_rate").(int), + TestType: d.Get("test_type").(string), + Paused: d.Get("paused").(bool), + Timeout: d.Get("timeout").(int), + ContactID: d.Get("contact_id").(int), + Confirmation: d.Get("confirmations").(int), } 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 { d.Set("paused", testResp.Paused) d.Set("timeout", testResp.Timeout) d.Set("contact_id", testResp.ContactID) + d.Set("confirmations", testResp.Confirmation) return nil } @@ -167,5 +173,8 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test { if v, ok := d.GetOk("contact_id"); ok { test.ContactID = v.(int) } + if v, ok := d.GetOk("confirmations"); ok { + test.Confirmation = v.(int) + } return test } diff --git a/resource_statuscaketest_test.go b/resource_statuscaketest_test.go index de30254..ac3cc92 100644 --- a/resource_statuscaketest_test.go +++ b/resource_statuscaketest_test.go @@ -52,6 +52,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) { resource.TestCheckResourceAttr("statuscake_test.google", "check_rate", "500"), resource.TestCheckResourceAttr("statuscake_test.google", "paused", "true"), resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"), + resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"), ), }, }, @@ -116,6 +117,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC err = check(key, value, strconv.Itoa(test.Timeout)) case "contact_id": err = check(key, value, strconv.Itoa(test.ContactID)) + case "confirmations": + err = check(key, value, strconv.Itoa(test.Confirmation)) } if err != nil { @@ -145,6 +148,7 @@ resource "statuscake_test" "google" { test_type = "HTTP" check_rate = 300 contact_id = 12345 + confirmations = 1 } ` -- cgit v1.2.3