Skip to content

Commit

Permalink
SYN-3741: Added automatic_retries to all /test api responses (#43)
Browse files Browse the repository at this point in the history
* Added automatic_retries to all /test api responses

* Updated the syntheticsclient module to 2.0.7

* Make automatic_retries an optinal attribute
  • Loading branch information
kparvin authored May 20, 2024
1 parent 0628737 commit a86c2bc
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 4 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.6
github.com/splunk/syntheticsclient/v2 v2.0.7
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +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/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=
Expand Down
4 changes: 4 additions & 0 deletions synthetics/data_source_apicheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ func dataSourceApiCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/data_source_browsercheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ func dataSourceBrowserCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/data_source_httpcheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func dataSourceHttpCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/data_source_portcheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func dataSourcePortCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions synthetics/resource_api_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func resourceApiCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/resource_api_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ resource "synthetics_create_api_check_v2" "api_v2_foo_check" {
location_ids = ["aws-us-east-1"]
name = "2 Terraform-Api V2 Acceptance Checkaroo"
scheduling_strategy = "round_robin"
automatic_retries = 1
custom_properties {
key = "key"
value = "value"
Expand Down Expand Up @@ -123,6 +124,7 @@ resource "synthetics_create_api_check_v2" "api_v2_foo_check" {
location_ids = ["aws-us-west-1"]
name = "2 Terraform-Api V2 Acceptance Checkaroo Updated"
scheduling_strategy = "concurrent"
automatic_retries = 0
custom_properties {
key = "beepkey"
value = "boopvalue"
Expand Down Expand Up @@ -220,6 +222,7 @@ func TestAccCreateUpdateApiCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.active", "true"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.device_id", "1"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.frequency", "5"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.automatic_retries", "1"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.location_ids.0", "aws-us-east-1"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.name", "2 Terraform-Api V2 Acceptance Checkaroo"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.scheduling_strategy", "round_robin"),
Expand Down Expand Up @@ -291,6 +294,7 @@ func TestAccCreateUpdateApiCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.active", "false"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.device_id", "2"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.frequency", "15"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.automatic_retries", "0"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.location_ids.0", "aws-us-west-1"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.name", "2 Terraform-Api V2 Acceptance Checkaroo Updated"),
resource.TestCheckResourceAttr("synthetics_create_api_check_v2.api_v2_foo_check", "test.0.scheduling_strategy", "concurrent"),
Expand Down
5 changes: 5 additions & 0 deletions synthetics/resource_browser_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ func resourceBrowserCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/resource_browser_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
device_id = 1
frequency = 5
location_ids = ["aws-us-east-1"]
automatic_retries = 1
name = "01-acceptance-Terraform-Browser-V2"
scheduling_strategy = "round_robin"
custom_properties {
Expand Down Expand Up @@ -133,6 +134,7 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
device_id = 2
frequency = 15
location_ids = ["aws-us-west-1"]
automatic_retries = 0
name = "01-acceptance-updated-Terraform-Browser-V2"
scheduling_strategy = "concurrent"
custom_properties {
Expand Down Expand Up @@ -261,6 +263,7 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.active", "true"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.device_id", "1"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.frequency", "5"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.automatic_retries", "1"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.location_ids.0", "aws-us-east-1"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.name", "01-acceptance-Terraform-Browser-V2"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.scheduling_strategy", "round_robin"),
Expand Down Expand Up @@ -337,6 +340,7 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.active", "false"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.device_id", "2"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.frequency", "15"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.automatic_retries", "0"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.location_ids.0", "aws-us-west-1"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.name", "01-acceptance-updated-Terraform-Browser-V2"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.scheduling_strategy", "concurrent"),
Expand Down
5 changes: 5 additions & 0 deletions synthetics/resource_http_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ func resourceHttpCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/resource_http_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ resource "synthetics_create_http_check_v2" "http_v2_foo_check" {
name = "01-acceptance-Terraform-HTTP-V2"
type = "http"
url = "https://www.splunk.com"
automatic_retries = 1
scheduling_strategy = "round_robin"
custom_properties {
key = "key"
Expand Down Expand Up @@ -75,6 +76,7 @@ resource "synthetics_create_http_check_v2" "http_v2_foo_check" {
name = "01-acceptance-updated-Terraform-HTTP-V2"
type = "http"
url = "https://www.duckduckgo.com"
automatic_retries = 0
scheduling_strategy = "concurrent"
custom_properties {
key = "beepkey"
Expand Down Expand Up @@ -123,6 +125,7 @@ func TestAccCreateUpdateHttpCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.#", "1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.active", "true"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.frequency", "5"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.automatic_retries", "1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.location_ids.0", "aws-us-east-1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.location_ids.1", "aws-us-west-1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.name", "01-acceptance-Terraform-HTTP-V2"),
Expand Down Expand Up @@ -164,6 +167,7 @@ func TestAccCreateUpdateHttpCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.#", "1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.active", "false"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.frequency", "15"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.automatic_retries", "0"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.location_ids.0", "aws-us-west-1"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.name", "01-acceptance-updated-Terraform-HTTP-V2"),
resource.TestCheckResourceAttr("synthetics_create_http_check_v2.http_v2_foo_check", "test.0.type", "http"),
Expand Down
5 changes: 5 additions & 0 deletions synthetics/resource_port_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func resourcePortCheckV2() *schema.Resource {
},
},
},
"automatic_retries": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions synthetics/resource_port_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ resource "synthetics_create_port_check_v2" "port_v2_foo_check" {
active = true
frequency = 5
location_ids = ["aws-us-west-2", "aws-us-east-1"]
automatic_retries = 1
scheduling_strategy = "round_robin"
custom_properties {
key = "key"
Expand All @@ -47,6 +48,7 @@ resource "synthetics_create_port_check_v2" "port_v2_foo_check" {
active = false
frequency = 15
location_ids = ["aws-us-east-1"]
automatic_retries = 0
scheduling_strategy = "concurrent"
custom_properties {
key = "beepkey"
Expand All @@ -73,6 +75,7 @@ func TestAccCreateUpdatePortCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.#", "1"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.active", "true"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.frequency", "5"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.automatic_retries", "1"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.location_ids.0", "aws-us-west-2"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.location_ids.1", "aws-us-east-1"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.scheduling_strategy", "round_robin"),
Expand All @@ -97,6 +100,7 @@ func TestAccCreateUpdatePortCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.#", "1"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.active", "false"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.frequency", "15"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.automatic_retries", "0"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.location_ids.0", "aws-us-east-1"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.scheduling_strategy", "concurrent"),
resource.TestCheckResourceAttr("synthetics_create_port_check_v2.port_v2_foo_check", "test.0.custom_properties.0.key", "beepkey"),
Expand Down
12 changes: 12 additions & 0 deletions synthetics/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func flattenApiV2Read(checkApiV2 *sc2.ApiCheckV2Response) []interface{} {
apiV2 := make(map[string]interface{})

apiV2["active"] = checkApiV2.Test.Active
apiV2["automatic_retries"] = checkApiV2.Test.Automaticretries

if checkApiV2.Test.Frequency != 0 {
apiV2["frequency"] = checkApiV2.Test.Frequency
Expand Down Expand Up @@ -81,6 +82,7 @@ func flattenApiV2Data(checkApiV2 *sc2.ApiCheckV2Response) []interface{} {
apiV2 := make(map[string]interface{})

apiV2["active"] = checkApiV2.Test.Active
apiV2["automatic_retries"] = checkApiV2.Test.Automaticretries

if checkApiV2.Test.Createdat.IsZero() {
} else {
Expand Down Expand Up @@ -312,6 +314,7 @@ func flattenBrowserV2Read(checkBrowserV2 *sc2.BrowserCheckV2Response) []interfac
browserV2 := make(map[string]interface{})

browserV2["active"] = checkBrowserV2.Test.Active
browserV2["automatic_retries"] = checkBrowserV2.Test.Automaticretries

browserV2["device_id"] = checkBrowserV2.Test.Device.ID

Expand Down Expand Up @@ -348,6 +351,7 @@ func flattenBrowserV2Data(checkBrowserV2 *sc2.BrowserCheckV2Response) []interfac
browserV2 := make(map[string]interface{})

browserV2["active"] = checkBrowserV2.Test.Active
browserV2["automatic_retries"] = checkBrowserV2.Test.Automaticretries

if checkBrowserV2.Test.Createdat.IsZero() {
} else {
Expand Down Expand Up @@ -419,6 +423,7 @@ func flattenHttpV2Read(checkHttpV2 *sc2.HttpCheckV2Response) []interface{} {
}

httpV2["active"] = checkHttpV2.Test.Active
httpV2["automatic_retries"] = checkHttpV2.Test.Automaticretries

if checkHttpV2.Test.Frequency != 0 {
httpV2["frequency"] = checkHttpV2.Test.Frequency
Expand Down Expand Up @@ -477,6 +482,7 @@ func flattenHttpV2Data(checkHttpV2 *sc2.HttpCheckV2Response) []interface{} {
}

httpV2["active"] = checkHttpV2.Test.Active
httpV2["automatic_retries"] = checkHttpV2.Test.Automaticretries

if checkHttpV2.Test.Frequency != 0 {
httpV2["frequency"] = checkHttpV2.Test.Frequency
Expand Down Expand Up @@ -554,6 +560,7 @@ func flattenPortCheckV2Read(checkPortV2 *sc2.PortCheckV2Response) []interface{}
}

portV2["active"] = checkPortV2.Test.Active
portV2["automatic_retries"] = checkPortV2.Test.Automaticretries

if checkPortV2.Test.Frequency != 0 {
portV2["frequency"] = checkPortV2.Test.Frequency
Expand Down Expand Up @@ -602,6 +609,7 @@ func flattenPortCheckV2Data(checkPortV2 *sc2.PortCheckV2Response) []interface{}
}

portV2["active"] = checkPortV2.Test.Active
portV2["automatic_retries"] = checkPortV2.Test.Automaticretries

if checkPortV2.Test.Frequency != 0 {
portV2["frequency"] = checkPortV2.Test.Frequency
Expand Down Expand Up @@ -1151,6 +1159,7 @@ func buildApiV2Data(d *schema.ResourceData) sc2.ApiCheckV2Input {
apiv2.Test.Active = api["active"].(bool)
apiv2.Test.Deviceid = api["device_id"].(int)
apiv2.Test.Frequency = api["frequency"].(int)
apiv2.Test.Automaticretries = api["automatic_retries"].(int)
apiv2.Test.Locationids = buildLocationIdData(api["location_ids"].([]interface{}))
apiv2.Test.Name = api["name"].(string)
apiv2.Test.Requests = buildRequestsData(api["requests"].(([]interface{})))
Expand All @@ -1171,6 +1180,7 @@ func buildBrowserV2Data(d *schema.ResourceData) sc2.BrowserCheckV2Input {
browserv2.Test.Active = browser["active"].(bool)
browserv2.Test.DeviceID = browser["device_id"].(int)
browserv2.Test.Frequency = browser["frequency"].(int)
browserv2.Test.Automaticretries = browser["automatic_retries"].(int)
browserv2.Test.LocationIds = buildLocationIdData(browser["location_ids"].([]interface{}))
browserv2.Test.Name = browser["name"].(string)
browserv2.Test.Transactions = buildBusinessTransactionsData(browser["transactions"].([]interface{}))
Expand All @@ -1195,6 +1205,7 @@ func buildHttpV2Data(d *schema.ResourceData) sc2.HttpCheckV2Input {
httpv2.Test.URL = http["url"].(string)
httpv2.Test.LocationIds = buildLocationIdData(http["location_ids"].([]interface{}))
httpv2.Test.Frequency = http["frequency"].(int)
httpv2.Test.Automaticretries = http["automatic_retries"].(int)
httpv2.Test.SchedulingStrategy = http["scheduling_strategy"].(string)
httpv2.Test.Active = http["active"].(bool)
httpv2.Test.RequestMethod = http["request_method"].(string)
Expand Down Expand Up @@ -1227,6 +1238,7 @@ func buildPortCheckV2Data(d *schema.ResourceData) sc2.PortCheckV2Input {
portv2.Test.Host = port["host"].(string)
portv2.Test.LocationIds = buildLocationIdData(port["location_ids"].([]interface{}))
portv2.Test.Frequency = port["frequency"].(int)
portv2.Test.Automaticretries = port["automatic_retries"].(int)
portv2.Test.SchedulingStrategy = port["scheduling_strategy"].(string)
portv2.Test.Active = port["active"].(bool)
portv2.Test.Customproperties = buildCustomPropertiesData(port["custom_properties"].(*schema.Set))
Expand Down
Loading

0 comments on commit a86c2bc

Please sign in to comment.