From b7255a63a92c38ee22555260b2d91256cee74bdb Mon Sep 17 00:00:00 2001 From: Nicholas Duffy <3457341+duffn@users.noreply.github.com> Date: Wed, 6 Oct 2021 14:13:30 -0600 Subject: [PATCH] Add option to create HTTP check with IPV6 --- pingdom/api_responses.go | 2 +- pingdom/check_types.go | 5 +++++ pingdom/check_types_test.go | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pingdom/api_responses.go b/pingdom/api_responses.go index 1579d72..5d1786e 100644 --- a/pingdom/api_responses.go +++ b/pingdom/api_responses.go @@ -40,7 +40,7 @@ type CheckResponse struct { Teams []CheckTeamResponse `json:"teams,omitempty"` ResponseTimeThreshold int `json:"responsetime_threshold,omitempty"` ProbeFilters []string `json:"probe_filters,omitempty"` - IP6 bool `json:"ip6,omitempty"` + IPV6 bool `json:"ipv6,omitempty"` // Legacy; this is not returned by the API, we backfill the value from the // Teams field. diff --git a/pingdom/check_types.go b/pingdom/check_types.go index 8a490eb..d286853 100644 --- a/pingdom/check_types.go +++ b/pingdom/check_types.go @@ -32,6 +32,7 @@ type HttpCheck struct { TeamIds []int `json:"teamids,omitempty"` VerifyCertificate *bool `json:"verify_certificate,omitempty"` SSLDownDaysBefore *int `json:"ssl_down_days_before,omitempty"` + IPV6 *bool `json:"ipv6,omitempty"` } // PingCheck represents a Pingdom ping check. @@ -122,6 +123,10 @@ func (ck *HttpCheck) PutParams() map[string]string { m["ssl_down_days_before"] = strconv.Itoa(*ck.SSLDownDaysBefore) } + if ck.IPV6 != nil { + m["ipv6"] = strconv.FormatBool(*ck.IPV6) + } + // ShouldContain and ShouldNotContain are mutually exclusive. // But we must define one so they can be emptied if required. if ck.ShouldContain != "" { diff --git a/pingdom/check_types_test.go b/pingdom/check_types_test.go index 5563057..eaff951 100644 --- a/pingdom/check_types_test.go +++ b/pingdom/check_types_test.go @@ -8,6 +8,7 @@ import ( func TestHttpCheckPutParams(t *testing.T) { verifyCertificate := true + ipv6 := true sslDownDaysBefore := 10 tests := []struct { @@ -33,6 +34,7 @@ func TestHttpCheckPutParams(t *testing.T) { ResponseTimeThreshold: 2300, VerifyCertificate: &verifyCertificate, SSLDownDaysBefore: &sslDownDaysBefore, + IPV6: &ipv6, }, wantParams: map[string]string{ "name": "fake check", @@ -56,6 +58,7 @@ func TestHttpCheckPutParams(t *testing.T) { "responsetime_threshold": "2300", "verify_certificate": "true", "ssl_down_days_before": "10", + "ipv6": "true", }, }, { @@ -109,6 +112,7 @@ func TestHttpCheckPutParams(t *testing.T) { func TestHttpCheckPostParams(t *testing.T) { verifyCertificate := true + ipv6 := true sslDownDaysBefore := 10 check := HttpCheck{ @@ -127,6 +131,7 @@ func TestHttpCheckPostParams(t *testing.T) { ResponseTimeThreshold: 2300, VerifyCertificate: &verifyCertificate, SSLDownDaysBefore: &sslDownDaysBefore, + IPV6: &ipv6, } want := map[string]string{ "name": "fake check", @@ -147,6 +152,7 @@ func TestHttpCheckPostParams(t *testing.T) { "responsetime_threshold": "2300", "verify_certificate": "true", "ssl_down_days_before": "10", + "ipv6": "true", } params := check.PostParams()