Skip to content

Commit

Permalink
SYN-3798: add last_run_status and last_run_at to /tests/ response (#42)
Browse files Browse the repository at this point in the history
* SYN-3798: add last_run_status and last_run_at to /tests/ response

* use github.com/splunk/syntheticsclient/v2 v2.0.6

* fix copy/paste

* fix copy/paste again

* lint

* lint again
  • Loading branch information
bchhay-splunk authored Apr 23, 2024
1 parent 016cc3f commit 3d51d05
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 8 additions & 0 deletions synthetics/data_source_apicheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions synthetics/data_source_browsercheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions synthetics/data_source_httpcheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions synthetics/data_source_portcheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
36 changes: 36 additions & 0 deletions synthetics/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d51d05

Please sign in to comment.