diff --git a/go.mod b/go.mod index 9faab65..2ab9960 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/splunk/syntheticsclient v1.0.3 - github.com/splunk/syntheticsclient/v2 v2.0.5 + github.com/splunk/syntheticsclient/v2 v2.0.7 ) require ( diff --git a/go.sum b/go.sum index 155cb5a..2efdbbe 100644 --- a/go.sum +++ b/go.sum @@ -176,6 +176,8 @@ github.com/splunk/syntheticsclient v1.0.3 h1:I3PUgTnKZsCNGFH8OgBiQ+sZYYxOwcLmkbi github.com/splunk/syntheticsclient v1.0.3/go.mod h1:riH4plM9ySr2lHnWi2E4cocaP9qqlRQHKX6nisiyq6E= github.com/splunk/syntheticsclient/v2 v2.0.5 h1:IWmXf1zqQMIrPNW/BYFe4geTvirXybWH7LXxkPBcZ8k= github.com/splunk/syntheticsclient/v2 v2.0.5/go.mod h1:xP4ikfSyA0eVyI72sa11hi9yUDBaQhB5mtW6QSClaWw= +github.com/splunk/syntheticsclient/v2 v2.0.7 h1:cfZPoIW/tX/5DiKLv+OZsiYiPGHYT1j5CsouGhSXZRw= +github.com/splunk/syntheticsclient/v2 v2.0.7/go.mod h1:xP4ikfSyA0eVyI72sa11hi9yUDBaQhB5mtW6QSClaWw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/common_models.go b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/common_models.go index fcb2abe..26febe0 100644 --- a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/common_models.go +++ b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/common_models.go @@ -150,14 +150,24 @@ type Tests []struct { Type string `json:"type"` Updatedat time.Time `json:"updatedAt"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` + Automaticretries int `json:"automaticRetries"` } type GetChecksV2Options struct { - TestType string `json:"testType"` - PerPage int `json:"perPage"` - Page int `json:"page"` - Search string `json:"search"` - OrderBy string `json:"orderBy"` + TestType string `json:"testType"` + PerPage int `json:"perPage"` + Page int `json:"page"` + Search string `json:"search"` + OrderBy string `json:"orderBy"` + Active *bool `json:"active"` + CustomProperties []CustomProperties `json:"customProperties"` + Frequencies []int `json:"frequencies"` + LastRunStatus []string `json:"lastRunStatus"` + LocationIds []string `json:"locationIds"` + SchedulingStrategy string `json:"schedulingStrategy"` + TestTypes []string `json:"testTypes"` } type Errors []struct { @@ -251,6 +261,9 @@ type PortCheckV2Response struct { Host string `json:"host"` Port int `json:"port"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` + Automaticretries int `json:"automaticRetries"` } `json:"test"` } @@ -267,6 +280,7 @@ type PortCheckV2Input struct { SchedulingStrategy string `json:"schedulingStrategy"` Active bool `json:"active"` Customproperties []CustomProperties `json:"customProperties"` + Automaticretries int `json:"automaticRetries"` } `json:"test"` } @@ -290,6 +304,10 @@ type HttpCheckV2Response struct { HttpHeaders []HttpHeaders `json:"headers,omitempty"` Validations []Validations `json:"validations"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` + Automaticretries int `json:"automaticRetries"` + Port int `json:"port"` } `json:"test"` } @@ -310,6 +328,8 @@ type HttpCheckV2Input struct { HttpHeaders []HttpHeaders `json:"headers,omitempty"` Validations []Validations `json:"validations"` Customproperties []CustomProperties `json:"customProperties"` + Automaticretries int `json:"automaticRetries"` + Port int `json:"port"` } `json:"test"` } @@ -323,6 +343,7 @@ type ApiCheckV2Input struct { Requests []Requests `json:"requests"` Schedulingstrategy string `json:"schedulingStrategy"` Customproperties []CustomProperties `json:"customProperties"` + Automaticretries int `json:"automaticRetries"` } `json:"test"` } @@ -340,6 +361,9 @@ type ApiCheckV2Response struct { Type string `json:"type,omitempty"` Updatedat time.Time `json:"updatedAt,omitempty"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` + Automaticretries int `json:"automaticRetries"` } } @@ -356,6 +380,7 @@ type BrowserCheckV2Input struct { Active bool `json:"active"` Advancedsettings `json:"advancedSettings,omitempty"` Customproperties []CustomProperties `json:"customProperties"` + Automaticretries int `json:"automaticRetries"` } `json:"test"` } @@ -374,6 +399,9 @@ type BrowserCheckV2Response struct { Type string `json:"type"` Updatedat time.Time `json:"updatedAt"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` + Automaticretries int `json:"automaticRetries"` } `json:"test"` } diff --git a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/get_checksv2.go b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/get_checksv2.go index fe825d5..8b6e328 100644 --- a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/get_checksv2.go +++ b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/get_checksv2.go @@ -18,6 +18,8 @@ import ( "bytes" "encoding/json" "fmt" + "strings" + "strconv" ) func parseChecksV2Response(response string) (*ChecksV2Response, error) { @@ -46,11 +48,27 @@ func (c Client) GetChecksV2(params *GetChecksV2Options) (*ChecksV2Response, *Req if params.PerPage == 0 { params.PerPage = int(50) } + if params.SchedulingStrategy == "" { + params.SchedulingStrategy = "" + } // Make the request details, err := c.makePublicAPICall( "GET", - fmt.Sprintf("/tests?testType=%s&page=%d&perPage=%d&orderBy=%s&search=%s", params.TestType, params.Page, params.PerPage, params.OrderBy, params.Search), + fmt.Sprintf("/tests?testType=%s&page=%d&perPage=%d&orderBy=%s&search=%s%s&schedulingStrategy=%s%s%s%s%s%s", + params.TestType, + params.Page, + params.PerPage, + params.OrderBy, + params.Search, + activeQueryParam(params.Active), + params.SchedulingStrategy, + customPropsQueryParam(params.CustomProperties), + stringsQueryParam(params.LastRunStatus, "&lastRunStatus[]="), + stringsQueryParam(params.LocationIds, "&locationIds[]="), + stringsQueryParam(params.TestTypes, "&testTypes[]="), + integersQueryParam(params.Frequencies, "&frequencies[]="), + ), bytes.NewBufferString("{}"), nil) @@ -66,3 +84,36 @@ func (c Client) GetChecksV2(params *GetChecksV2Options) (*ChecksV2Response, *Req return check, details, nil } + +func activeQueryParam(param *bool) (string) { + if param != nil { + boolString := strconv.FormatBool(*param) + return fmt.Sprintf("&active=%s", boolString) + } + return "" +} + +func customPropsQueryParam(params []CustomProperties) (string) { + if len(params) == 0 { + return "" + } + var result string + for _, customProp := range params { + result += "&customProperties[]=" + customProp.Key + ":" + customProp.Value + } + return result +} + +func integersQueryParam(params []int, queryParamName string) (string) { + if len(params) == 0 { + return "" + } + return queryParamName + strings.Trim(strings.Replace(fmt.Sprint(params), " ", queryParamName, -1), "[]") +} + +func stringsQueryParam(params []string, queryParamName string) (string) { + if len(params) == 0 { + return "" + } + return queryParamName + strings.Join(params, queryParamName) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6ab9e19..9d643a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -175,7 +175,7 @@ github.com/oklog/run # github.com/splunk/syntheticsclient v1.0.3 ## explicit; go 1.14 github.com/splunk/syntheticsclient/syntheticsclient -# github.com/splunk/syntheticsclient/v2 v2.0.5 +# github.com/splunk/syntheticsclient/v2 v2.0.7 ## explicit; go 1.14 github.com/splunk/syntheticsclient/v2/syntheticsclientv2 # github.com/vmihailenco/msgpack v4.0.4+incompatible