Skip to content

Commit

Permalink
Merge pull request #46 from Constellix/notification_report_timeout
Browse files Browse the repository at this point in the history
fixed http/tcp/dns check issues
  • Loading branch information
jr-frazier authored Mar 2, 2022
2 parents 509df23 + cc61a33 commit 9e7fa41
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 deletions.
6 changes: 6 additions & 0 deletions constellix/datasource_constellix_dns_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func datasourceConstellixDNSCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -125,6 +130,7 @@ func datasourceConstellixDNSCheckRead(d *schema.ResourceData, m interface{}) err
d.Set("interval_policy", tp["monitorIntervalPolicy"])
d.Set("verification_policy", tp["verificationPolicy"])
d.Set("expected_response", tp["expectedResponse"])
d.Set("notification_report_timeout", tp["notificationReportTimeout"])
}
}
if flag == false {
Expand Down
6 changes: 6 additions & 0 deletions constellix/datasource_constellix_http_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ func datasourceConstellixHTTPCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -156,6 +161,7 @@ func datasourceConstellixHTTPCheckRead(d *schema.ResourceData, m interface{}) er
d.Set("path", tp["path"])
d.Set("search_string", tp["searchString"])
d.Set("expected_status_code", tp["expectedStatusCode"])
d.Set("notification_report_timeout", tp["notificationReportTimeout"])
}
}
if flag != true {
Expand Down
6 changes: 6 additions & 0 deletions constellix/datasource_constellix_tcp_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func datasourceConstellixTCPCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -135,6 +140,7 @@ func datasourceConstellixTCPCheckRead(d *schema.ResourceData, m interface{}) err
d.Set("verification_policy", tp["verificationPolicy"])
d.Set("string_to_send", tp["stringToSend"])
d.Set("string_to_receive", tp["stringToReceive"])
d.Set("notification_report_timeout", tp["notificationReportTimeout"])
}
}
if flag != true {
Expand Down
15 changes: 15 additions & 0 deletions constellix/resource_constellix_dns_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func resourceConstellixDNSCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -131,6 +136,7 @@ func resourceConstellixDNSCheckImport(d *schema.ResourceData, m interface{}) ([]
d.Set("interval_policy", data["monitorIntervalPolicy"])
d.Set("verification_policy", data["verificationPolicy"])
d.Set("expected_response", data["expectedResponse"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
log.Printf("[DEBUG] %s finished import", d.Id())
return []*schema.ResourceData{d}, nil
}
Expand Down Expand Up @@ -165,6 +171,10 @@ func resourceConstellixDNSCheckCreate(d *schema.ResourceData, m interface{}) err
dnsAttr.Interval = interval.(string)
}

if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
dnsAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

if interval_policy, ok := d.GetOk("interval_policy"); ok {
dnsAttr.IntervalPolicy = interval_policy.(string)
}
Expand Down Expand Up @@ -229,6 +239,7 @@ func resourceConstellixDNSCheckRead(d *schema.ResourceData, m interface{}) error
d.Set("interval_policy", data["monitorIntervalPolicy"])
d.Set("verification_policy", data["verificationPolicy"])
d.Set("expected_response", data["expectedResponse"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
return nil
}

Expand Down Expand Up @@ -265,6 +276,10 @@ func resourceConstellixDNSCheckUpdate(d *schema.ResourceData, m interface{}) err
dnsAttr.ExpectedResponse = expected_response.(string)
}

if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
dnsAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

dn := d.Id()
resp, err := client.UpdatebyID(dnsAttr, "https://api.sonar.constellix.com/rest/api/dns/"+dn)
defer resp.Body.Close()
Expand Down
31 changes: 23 additions & 8 deletions constellix/resource_constellix_http_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func resourceConstellixHTTPCheck() *schema.Resource {
},

"check_sites": &schema.Schema{
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{Type: schema.TypeInt},
},

"notification_groups": &schema.Schema{
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeInt},
Expand Down Expand Up @@ -121,6 +121,11 @@ func resourceConstellixHTTPCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -157,6 +162,7 @@ func resourceConstellixHTTPCheckImport(d *schema.ResourceData, m interface{}) ([
d.Set("path", data["path"])
d.Set("search_string", data["searchString"])
d.Set("expected_status_code", data["expectedStatusCode"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
log.Printf("[DEBUG] %s finished import", d.Id())
return []*schema.ResourceData{d}, nil
}
Expand Down Expand Up @@ -187,11 +193,15 @@ func resourceConstellixHTTPCheckCreate(d *schema.ResourceData, m interface{}) er
}

if checksites, ok := d.GetOk("check_sites"); ok {
httpcheckAttr.Checksites = checksites.([]interface{})
httpcheckAttr.Checksites = checksites.(*schema.Set).List()
}

if notficationGrp, ok := d.GetOk("notification_groups"); ok {
httpcheckAttr.NotificationGroups = toListOfInt(notficationGrp)
if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
httpcheckAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

if notificationGrp, ok := d.GetOk("notification_groups"); ok {
httpcheckAttr.NotificationGroups = toListOfInt(notificationGrp.(*schema.Set).List())
}

if interval, ok := d.GetOk("interval"); ok {
Expand Down Expand Up @@ -259,11 +269,15 @@ func resourceConstellixHTTPCheckUpdate(d *schema.ResourceData, m interface{}) er
}

if checksites, ok := d.GetOk("check_sites"); ok {
httpcheckAttr.Checksites = checksites.([]interface{})
httpcheckAttr.Checksites = checksites.(*schema.Set).List()
}

if notificationGrp, ok := d.GetOk("notification_groups"); ok {
httpcheckAttr.NotificationGroups = toListOfInt(notificationGrp.(*schema.Set).List())
}

if notficationGrp, ok := d.GetOk("notification_groups"); ok {
httpcheckAttr.NotificationGroups = toListOfInt(notficationGrp)
if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
httpcheckAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

if interval, ok := d.GetOk("interval"); ok {
Expand Down Expand Up @@ -330,6 +344,7 @@ func resourceConstellixHTTPCheckRead(d *schema.ResourceData, m interface{}) erro
d.Set("path", data["path"])
d.Set("search_string", data["searchString"])
d.Set("expected_status_code", data["expectedStatusCode"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
return nil
}

Expand Down
15 changes: 15 additions & 0 deletions constellix/resource_constellix_tcp_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func resourceConstellixTCPCheck() *schema.Resource {
Optional: true,
Computed: true,
},
"notification_report_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -138,6 +143,7 @@ func resourceConstellixTCPCheckImport(d *schema.ResourceData, m interface{}) ([]
d.Set("interval_policy", data["monitorIntervalPolicy"])
d.Set("string_to_send", data["stringToSend"])
d.Set("string_to_receive", data["stringToReceive"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
log.Printf("[DEBUG] %s finished import", d.Id())
return []*schema.ResourceData{d}, nil
}
Expand Down Expand Up @@ -172,6 +178,10 @@ func resourceConstellixTCPCheckCreate(d *schema.ResourceData, m interface{}) err
tcpcheckAttr.NotificationGroups = toListOfInt(notficationGrp)
}

if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
tcpcheckAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

if interval, ok := d.GetOk("interval"); ok {
tcpcheckAttr.Interval = interval.(string)
}
Expand Down Expand Up @@ -234,6 +244,10 @@ func resourceConstellixTCPCheckUpdate(d *schema.ResourceData, m interface{}) err
tcpcheckAttr.NotificationGroups = toListOfInt(notficationGrp)
}

if notificationReportTimeout, ok := d.GetOk("notification_report_timeout"); ok {
tcpcheckAttr.NotificationReportTimeout = notificationReportTimeout.(int)
}

if interval, ok := d.GetOk("interval"); ok {
tcpcheckAttr.Interval = interval.(string)
}
Expand Down Expand Up @@ -288,6 +302,7 @@ func resourceConstellixTCPCheckRead(d *schema.ResourceData, m interface{}) error
d.Set("interval_policy", data["monitorIntervalPolicy"])
d.Set("string_to_send", data["stringToSend"])
d.Set("string_to_receive", data["stringToReceive"])
d.Set("notification_report_timeout", data["notificationReportTimeout"])
return nil
}

Expand Down

0 comments on commit 9e7fa41

Please sign in to comment.