X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=resource_statuscaketest.go;h=dbc15c9fbc84339f91c043199ebffcd3827a94dd;hb=90db3fb0ba1aff53f83ece8f5d62f56943ed090e;hp=a1d735415b7a1ecaff710fbb6ef3ed4c53e00194;hpb=312d16361a769314812c256f7433bcb0f2c72193;p=github%2Ffretlink%2Fterraform-provider-statuscake.git diff --git a/resource_statuscaketest.go b/resource_statuscaketest.go index a1d7354..dbc15c9 100644 --- a/resource_statuscaketest.go +++ b/resource_statuscaketest.go @@ -18,45 +18,57 @@ func resourceStatusCakeTest() *schema.Resource { Read: ReadTest, Schema: map[string]*schema.Schema{ - "test_id": &schema.Schema{ + "test_id": { Type: schema.TypeString, Computed: true, }, - "website_name": &schema.Schema{ + "website_name": { Type: schema.TypeString, Required: true, }, - "website_url": &schema.Schema{ + "website_url": { Type: schema.TypeString, Required: true, }, - "contact_id": &schema.Schema{ + "contact_id": { Type: schema.TypeInt, Optional: true, }, - "check_rate": &schema.Schema{ + "check_rate": { Type: schema.TypeInt, Optional: true, Default: 300, }, - "test_type": &schema.Schema{ + "test_type": { Type: schema.TypeString, Required: true, }, - "paused": &schema.Schema{ + "paused": { Type: schema.TypeBool, Optional: true, Default: false, }, - "timeout": &schema.Schema{ + + "timeout": { Type: schema.TypeInt, - Computed: true, + Optional: true, + Default: 40, + }, + + "confirmations": { + Type: schema.TypeInt, + Optional: true, + }, + + "port": { + Type: schema.TypeInt, + Optional: true, }, }, } @@ -66,10 +78,15 @@ 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), - TestType: d.Get("test_type").(string), - CheckRate: d.Get("check_rate").(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), + Port: d.Get("port").(int), } log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string)) @@ -125,7 +142,15 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error { if err != nil { return fmt.Errorf("Error Getting StatusCake Test Details for %s: Error: %s", d.Id(), err) } + d.Set("website_name", testResp.WebsiteName) + d.Set("website_url", testResp.WebsiteURL) d.Set("check_rate", testResp.CheckRate) + d.Set("test_type", testResp.TestType) + d.Set("paused", testResp.Paused) + d.Set("timeout", testResp.Timeout) + d.Set("contact_id", testResp.ContactID) + d.Set("confirmations", testResp.Confirmation) + d.Set("port", testResp.Port) return nil } @@ -162,5 +187,11 @@ 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) + } + if v, ok := d.GetOk("port"); ok { + test.Port = v.(int) + } return test }