diff --git a/go.mod b/go.mod index 9faab65..489a5d8 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.6 ) require ( diff --git a/go.sum b/go.sum index 155cb5a..87aa2ca 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.6 h1:YmMLAVhNV0gcO154Vx7Ab7gnP2iPPkOeFskTFsuj9Gk= +github.com/splunk/syntheticsclient/v2 v2.0.6/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/synthetics/data_source_apicheck_v2.go b/synthetics/data_source_apicheck_v2.go index d4edddc..e3765f4 100644 --- a/synthetics/data_source_apicheck_v2.go +++ b/synthetics/data_source_apicheck_v2.go @@ -253,6 +253,14 @@ func dataSourceApiCheckV2() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "last_run_at": { + Type: schema.TypeString, + Computed: true, + }, + "last_run_status": { + Type: schema.TypeString, + Computed: true, + }, "custom_properties": { Type: schema.TypeSet, Computed: true, diff --git a/synthetics/data_source_browsercheck_v2.go b/synthetics/data_source_browsercheck_v2.go index 17514fc..2d9fc62 100644 --- a/synthetics/data_source_browsercheck_v2.go +++ b/synthetics/data_source_browsercheck_v2.go @@ -61,6 +61,14 @@ func dataSourceBrowserCheckV2() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "last_run_at": { + Type: schema.TypeString, + Computed: true, + }, + "last_run_status": { + Type: schema.TypeString, + Computed: true, + }, "location_ids": { Type: schema.TypeList, Computed: true, diff --git a/synthetics/data_source_httpcheck_v2.go b/synthetics/data_source_httpcheck_v2.go index 2b46d8b..bfdbac7 100644 --- a/synthetics/data_source_httpcheck_v2.go +++ b/synthetics/data_source_httpcheck_v2.go @@ -62,6 +62,14 @@ func dataSourceHttpCheckV2() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "last_run_at": { + Type: schema.TypeString, + Computed: true, + }, + "last_run_status": { + Type: schema.TypeString, + Computed: true, + }, "body": { Type: schema.TypeString, Computed: true, diff --git a/synthetics/data_source_portcheck_v2.go b/synthetics/data_source_portcheck_v2.go index 15ce570..0c0368f 100644 --- a/synthetics/data_source_portcheck_v2.go +++ b/synthetics/data_source_portcheck_v2.go @@ -61,6 +61,14 @@ func dataSourcePortCheckV2() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "last_run_at": { + Type: schema.TypeString, + Computed: true, + }, + "last_run_status": { + Type: schema.TypeString, + Computed: true, + }, "location_ids": { Type: schema.TypeList, Optional: true, diff --git a/synthetics/structures.go b/synthetics/structures.go index f2034ee..5fb697a 100644 --- a/synthetics/structures.go +++ b/synthetics/structures.go @@ -92,6 +92,15 @@ func flattenApiV2Data(checkApiV2 *sc2.ApiCheckV2Response) []interface{} { apiV2["updated_at"] = checkApiV2.Test.Updatedat.String() } + if checkApiV2.Test.Lastrunat.IsZero() { + } else { + apiV2["last_run_at"] = checkApiV2.Test.Lastrunat.String() + } + + if checkApiV2.Test.Lastrunstatus != "" { + apiV2["last_run_status"] = checkApiV2.Test.Lastrunstatus + } + if checkApiV2.Test.Frequency != 0 { apiV2["frequency"] = checkApiV2.Test.Frequency } @@ -350,6 +359,15 @@ func flattenBrowserV2Data(checkBrowserV2 *sc2.BrowserCheckV2Response) []interfac browserV2["updated_at"] = checkBrowserV2.Test.Updatedat.String() } + if checkBrowserV2.Test.Lastrunat.IsZero() { + } else { + browserV2["last_run_at"] = checkBrowserV2.Test.Lastrunat.String() + } + + if checkBrowserV2.Test.Lastrunstatus != "" { + browserV2["last_run_status"] = checkBrowserV2.Test.Lastrunstatus + } + if checkBrowserV2.Test.Frequency != 0 { browserV2["frequency"] = checkBrowserV2.Test.Frequency } @@ -474,6 +492,15 @@ func flattenHttpV2Data(checkHttpV2 *sc2.HttpCheckV2Response) []interface{} { httpV2["updated_at"] = checkHttpV2.Test.UpdatedAt.String() } + if checkHttpV2.Test.Lastrunat.IsZero() { + } else { + httpV2["last_run_at"] = checkHttpV2.Test.Lastrunat.String() + } + + if checkHttpV2.Test.Lastrunstatus != "" { + httpV2["last_run_status"] = checkHttpV2.Test.Lastrunstatus + } + if checkHttpV2.Test.SchedulingStrategy != "" { httpV2["scheduling_strategy"] = checkHttpV2.Test.SchedulingStrategy } @@ -590,6 +617,15 @@ func flattenPortCheckV2Data(checkPortV2 *sc2.PortCheckV2Response) []interface{} portV2["updated_at"] = checkPortV2.Test.UpdatedAt.String() } + if checkPortV2.Test.Lastrunat.IsZero() { + } else { + portV2["last_run_at"] = checkPortV2.Test.Lastrunat.String() + } + + if checkPortV2.Test.Lastrunstatus != "" { + portV2["last_run_status"] = checkPortV2.Test.Lastrunstatus + } + if checkPortV2.Test.SchedulingStrategy != "" { portV2["scheduling_strategy"] = checkPortV2.Test.SchedulingStrategy } 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..d6d543c 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,23 @@ 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"` } 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 +260,8 @@ type PortCheckV2Response struct { Host string `json:"host"` Port int `json:"port"` Customproperties []CustomProperties `json:"customProperties"` + Lastrunstatus string `json:"lastRunStatus"` + Lastrunat time.Time `json:"lastRunAt"` } `json:"test"` } @@ -290,6 +301,8 @@ 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"` } `json:"test"` } @@ -340,6 +353,8 @@ 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"` } } @@ -374,6 +389,8 @@ 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"` } `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..b24a85c 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.6 ## explicit; go 1.14 github.com/splunk/syntheticsclient/v2/syntheticsclientv2 # github.com/vmihailenco/msgpack v4.0.4+incompatible