aboutsummaryrefslogtreecommitdiffhomepage
path: root/statuscake/resource_statuscaketest.go
diff options
context:
space:
mode:
Diffstat (limited to 'statuscake/resource_statuscaketest.go')
-rw-r--r--statuscake/resource_statuscaketest.go258
1 files changed, 236 insertions, 22 deletions
diff --git a/statuscake/resource_statuscaketest.go b/statuscake/resource_statuscaketest.go
index 101ee83..27cf9bf 100644
--- a/statuscake/resource_statuscaketest.go
+++ b/statuscake/resource_statuscaketest.go
@@ -34,7 +34,7 @@ func resourceStatusCakeTest() *schema.Resource {
34 }, 34 },
35 35
36 "contact_id": { 36 "contact_id": {
37 Type: schema.TypeInt, 37 Type: schema.TypeString,
38 Optional: true, 38 Optional: true,
39 }, 39 },
40 40
@@ -76,6 +76,120 @@ func resourceStatusCakeTest() *schema.Resource {
76 Optional: true, 76 Optional: true,
77 Default: 5, 77 Default: 5,
78 }, 78 },
79 "custom_header": {
80 Type: schema.TypeString,
81 Optional: true,
82 },
83
84 "user_agent": {
85 Type: schema.TypeString,
86 Optional: true,
87 },
88
89 "status": {
90 Type: schema.TypeString,
91 Optional: true,
92 },
93
94 "uptime": {
95 Type: schema.TypeFloat,
96 Optional: true,
97 },
98
99 "node_locations": {
100 Type: schema.TypeList,
101 Elem: &schema.Schema{Type: schema.TypeString},
102 Optional: true,
103 },
104
105 "ping_url": {
106 Type: schema.TypeString,
107 Optional: true,
108 },
109
110 "basic_user": {
111 Type: schema.TypeString,
112 Optional: true,
113 },
114
115 "basic_pass": {
116 Type: schema.TypeString,
117 Optional: true,
118 },
119
120 "public": {
121 Type: schema.TypeInt,
122 Optional: true,
123 },
124
125 "logo_image": {
126 Type: schema.TypeString,
127 Optional: true,
128 },
129
130 "branding": {
131 Type: schema.TypeInt,
132 Optional: true,
133 },
134
135 "website_host": {
136 Type: schema.TypeString,
137 Optional: true,
138 },
139
140 "virus": {
141 Type: schema.TypeInt,
142 Optional: true,
143 },
144
145 "find_string": {
146 Type: schema.TypeString,
147 Optional: true,
148 },
149
150 "do_not_find": {
151 Type: schema.TypeBool,
152 Optional: true,
153 },
154
155 "real_browser": {
156 Type: schema.TypeInt,
157 Optional: true,
158 },
159
160 "test_tags": {
161 Type: schema.TypeString,
162 Optional: true,
163 },
164
165 "status_codes": {
166 Type: schema.TypeString,
167 Optional: true,
168 Default: "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " +
169 "408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " +
170 "504, 505, 506, 507, 508, 509, 510, 511, 521, 522, 523, 524, 520, " +
171 "598, 599",
172 },
173
174 "use_jar": {
175 Type: schema.TypeInt,
176 Optional: true,
177 },
178
179 "post_raw": {
180 Type: schema.TypeString,
181 Optional: true,
182 },
183
184 "final_endpoint": {
185 Type: schema.TypeString,
186 Optional: true,
187 },
188
189 "follow_redirect": {
190 Type: schema.TypeBool,
191 Optional: true,
192 },
79 }, 193 },
80 } 194 }
81} 195}
@@ -84,16 +198,38 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
84 client := meta.(*statuscake.Client) 198 client := meta.(*statuscake.Client)
85 199
86 newTest := &statuscake.Test{ 200 newTest := &statuscake.Test{
87 WebsiteName: d.Get("website_name").(string), 201 WebsiteName: d.Get("website_name").(string),
88 WebsiteURL: d.Get("website_url").(string), 202 WebsiteURL: d.Get("website_url").(string),
89 CheckRate: d.Get("check_rate").(int), 203 CheckRate: d.Get("check_rate").(int),
90 TestType: d.Get("test_type").(string), 204 TestType: d.Get("test_type").(string),
91 Paused: d.Get("paused").(bool), 205 Paused: d.Get("paused").(bool),
92 Timeout: d.Get("timeout").(int), 206 Timeout: d.Get("timeout").(int),
93 ContactID: d.Get("contact_id").(int), 207 ContactID: d.Get("contact_id").(string),
94 Confirmation: d.Get("confirmations").(int), 208 Confirmation: d.Get("confirmations").(int),
95 Port: d.Get("port").(int), 209 Port: d.Get("port").(int),
96 TriggerRate: d.Get("trigger_rate").(int), 210 TriggerRate: d.Get("trigger_rate").(int),
211 CustomHeader: d.Get("custom_header").(string),
212 UserAgent: d.Get("user_agent").(string),
213 Status: d.Get("status").(string),
214 Uptime: d.Get("uptime").(float64),
215 NodeLocations: d.Get("node_locations").([]string),
216 PingURL: d.Get("ping_url").(string),
217 BasicUser: d.Get("basic_user").(string),
218 BasicPass: d.Get("basic_pass").(string),
219 Public: d.Get("public").(int),
220 LogoImage: d.Get("logo_image").(string),
221 Branding: d.Get("branding").(int),
222 WebsiteHost: d.Get("website_host").(string),
223 Virus: d.Get("virus").(int),
224 FindString: d.Get("find_string").(string),
225 DoNotFind: d.Get("do_not_find").(bool),
226 RealBrowser: d.Get("real_browser").(int),
227 TestTags: d.Get("test_tags").(string),
228 StatusCodes: d.Get("status_codes").(string),
229 UseJar: d.Get("use_jar").(int),
230 PostRaw: d.Get("post_raw").(string),
231 FinalEndpoint: d.Get("final_endpoint").(string),
232 FollowRedirect: d.Get("follow_redirect").(bool),
97 } 233 }
98 234
99 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string)) 235 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -159,6 +295,28 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
159 d.Set("confirmations", testResp.Confirmation) 295 d.Set("confirmations", testResp.Confirmation)
160 d.Set("port", testResp.Port) 296 d.Set("port", testResp.Port)
161 d.Set("trigger_rate", testResp.TriggerRate) 297 d.Set("trigger_rate", testResp.TriggerRate)
298 d.Set("custom_header", testResp.CustomHeader)
299 d.Set("user_agent", testResp.UserAgent)
300 d.Set("status", testResp.Status)
301 d.Set("uptime", testResp.Uptime)
302 d.Set("node_locations", testResp.NodeLocations)
303 d.Set("ping_url", testResp.PingURL)
304 d.Set("basic_user", testResp.BasicUser)
305 d.Set("basic_pass", testResp.BasicPass)
306 d.Set("public", testResp.Public)
307 d.Set("logo_image", testResp.LogoImage)
308 d.Set("branding", testResp.Branding)
309 d.Set("website_host", testResp.WebsiteHost)
310 d.Set("virus", testResp.Virus)
311 d.Set("find_string", testResp.FindString)
312 d.Set("do_not_find", testResp.DoNotFind)
313 d.Set("real_browser", testResp.RealBrowser)
314 d.Set("test_tags", testResp.TestTags)
315 d.Set("status_codes", testResp.StatusCodes)
316 d.Set("use_jar", testResp.UseJar)
317 d.Set("post_raw", testResp.PostRaw)
318 d.Set("final_endpoint", testResp.FinalEndpoint)
319 d.Set("follow_redirect", testResp.FollowRedirect)
162 320
163 return nil 321 return nil
164} 322}
@@ -181,7 +339,7 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
181 test.CheckRate = v.(int) 339 test.CheckRate = v.(int)
182 } 340 }
183 if v, ok := d.GetOk("contact_id"); ok { 341 if v, ok := d.GetOk("contact_id"); ok {
184 test.ContactID = v.(int) 342 test.ContactID = v.(string)
185 } 343 }
186 if v, ok := d.GetOk("test_type"); ok { 344 if v, ok := d.GetOk("test_type"); ok {
187 test.TestType = v.(string) 345 test.TestType = v.(string)
@@ -192,9 +350,6 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
192 if v, ok := d.GetOk("timeout"); ok { 350 if v, ok := d.GetOk("timeout"); ok {
193 test.Timeout = v.(int) 351 test.Timeout = v.(int)
194 } 352 }
195 if v, ok := d.GetOk("contact_id"); ok {
196 test.ContactID = v.(int)
197 }
198 if v, ok := d.GetOk("confirmations"); ok { 353 if v, ok := d.GetOk("confirmations"); ok {
199 test.Confirmation = v.(int) 354 test.Confirmation = v.(int)
200 } 355 }
@@ -204,13 +359,72 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
204 if v, ok := d.GetOk("trigger_rate"); ok { 359 if v, ok := d.GetOk("trigger_rate"); ok {
205 test.TriggerRate = v.(int) 360 test.TriggerRate = v.(int)
206 } 361 }
207 362 if v, ok := d.GetOk("custom_header"); ok {
208 defaultStatusCodes := "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " + 363 test.CustomHeader = v.(string)
209 "408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " + 364 }
210 "504, 505, 506, 507, 508, 509, 510, 511, 521, 522, 523, 524, 520, " + 365 if v, ok := d.GetOk("user_agent"); ok {
211 "598, 599" 366 test.UserAgent = v.(string)
212 367 }
213 test.StatusCodes = defaultStatusCodes 368 if v, ok := d.GetOk("status"); ok {
369 test.Status = v.(string)
370 }
371 if v, ok := d.GetOk("uptime"); ok {
372 test.Uptime = v.(float64)
373 }
374 if v, ok := d.GetOk("node_locations"); ok {
375 test.NodeLocations = v.([]string)
376 }
377 if v, ok := d.GetOk("ping_url"); ok {
378 test.PingURL = v.(string)
379 }
380 if v, ok := d.GetOk("basic_user"); ok {
381 test.BasicUser = v.(string)
382 }
383 if v, ok := d.GetOk("basic_pass"); ok {
384 test.BasicPass = v.(string)
385 }
386 if v, ok := d.GetOk("public"); ok {
387 test.Public = v.(int)
388 }
389 if v, ok := d.GetOk("logo_image"); ok {
390 test.LogoImage = v.(string)
391 }
392 if v, ok := d.GetOk("branding"); ok {
393 test.Branding = v.(int)
394 }
395 if v, ok := d.GetOk("website_host"); ok {
396 test.WebsiteHost = v.(string)
397 }
398 if v, ok := d.GetOk("virus"); ok {
399 test.Virus = v.(int)
400 }
401 if v, ok := d.GetOk("find_string"); ok {
402 test.FindString = v.(string)
403 }
404 if v, ok := d.GetOk("do_not_find"); ok {
405 test.DoNotFind = v.(bool)
406 }
407 if v, ok := d.GetOk("real_browser"); ok {
408 test.RealBrowser = v.(int)
409 }
410 if v, ok := d.GetOk("test_tags"); ok {
411 test.TestTags = v.(string)
412 }
413 if v, ok := d.GetOk("status_codes"); ok {
414 test.StatusCodes = v.(string)
415 }
416 if v, ok := d.GetOk("use_jar"); ok {
417 test.UseJar = v.(int)
418 }
419 if v, ok := d.GetOk("post_raw"); ok {
420 test.PostRaw = v.(string)
421 }
422 if v, ok := d.GetOk("final_endpoint"); ok {
423 test.FinalEndpoint = v.(string)
424 }
425 if v, ok := d.GetOk("follow_redirect"); ok {
426 test.FollowRedirect = v.(bool)
427 }
214 428
215 return test 429 return test
216} 430}