diff --git a/docs/data-sources/policy_object_feature_profile.md b/docs/data-sources/policy_object_feature_profile.md index 12a6b1e5..302f195b 100644 --- a/docs/data-sources/policy_object_feature_profile.md +++ b/docs/data-sources/policy_object_feature_profile.md @@ -21,11 +21,8 @@ data "sdwan_policy_object_feature_profile" "example" { ## Schema -### Required - -- `id` (String) The id of the object - ### Read-Only - `description` (String) Description +- `id` (String) The id of the object - `name` (String) The name of the policy object feature profile diff --git a/docs/resources/policy_object_feature_profile.md b/docs/resources/policy_object_feature_profile.md index 237f4052..af858513 100644 --- a/docs/resources/policy_object_feature_profile.md +++ b/docs/resources/policy_object_feature_profile.md @@ -3,12 +3,12 @@ page_title: "sdwan_policy_object_feature_profile Resource - terraform-provider-sdwan" subcategory: "Feature Profiles" description: |- - This resource can manage a Policy Object Feature Profile . + SD-WAN manager supports only a single policy object feature profile to be configured. This resource will therefore either create a new one if none exists or update the existing one. --- # sdwan_policy_object_feature_profile (Resource) -This resource can manage a Policy Object Feature Profile . +SD-WAN manager supports only a single policy object feature profile to be configured. This resource will therefore either create a new one if none exists or update the existing one. ## Example Usage diff --git a/gen/definitions/generic/policy_object_feature_profile.yaml b/gen/definitions/generic/policy_object_feature_profile.yaml index 690d67f9..31763330 100644 --- a/gen/definitions/generic/policy_object_feature_profile.yaml +++ b/gen/definitions/generic/policy_object_feature_profile.yaml @@ -2,6 +2,7 @@ name: Policy Object Feature Profile rest_endpoint: /v1/feature-profile/sdwan/policy-object/ id_attribute: id +res_description: SD-WAN manager supports only a single policy object feature profile to be configured. This resource will therefore either create a new one if none exists or update the existing one. doc_category: Feature Profiles test_tags: [SDWAN_2012] attributes: diff --git a/gen/definitions/profile_parcels/policy_object_class_map.yaml b/gen/definitions/profile_parcels/policy_object_class_map.yaml index a76eda24..bf50f314 100644 --- a/gen/definitions/profile_parcels/policy_object_class_map.yaml +++ b/gen/definitions/profile_parcels/policy_object_class_map.yaml @@ -2,7 +2,7 @@ name: Policy Object Class Map rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/class minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,14 +12,14 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: queue - id: true - mandatory: true - example: 0 + - model_name: queue + id: true + mandatory: true + example: 0 test_prerequisites: | - variable "policy_object_feature_template_id" {} \ No newline at end of file + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_color_list.yaml b/gen/definitions/profile_parcels/policy_object_color_list.yaml index 873518e3..7cbf89c5 100644 --- a/gen/definitions/profile_parcels/policy_object_color_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_color_list.yaml @@ -2,7 +2,7 @@ name: Policy Object Color List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/color minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,14 +12,14 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: color - id: true - mandatory: true - example: blue + - model_name: color + id: true + mandatory: true + example: blue test_prerequisites: | - variable "policy_object_feature_template_id" {} \ No newline at end of file + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_data_ipv4_prefix_list.yaml b/gen/definitions/profile_parcels/policy_object_data_ipv4_prefix_list.yaml index 3ba95462..f1ea501e 100644 --- a/gen/definitions/profile_parcels/policy_object_data_ipv4_prefix_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_data_ipv4_prefix_list.yaml @@ -2,7 +2,7 @@ name: Policy Object Data IPv4 Prefix List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/data-prefix minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,17 +12,17 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: ipv4Address - id: true - mandatory: true - example: 10.0.0.0 - - model_name: ipv4PrefixLength - mandatory: true - example: 8 + - model_name: ipv4Address + id: true + mandatory: true + example: 10.0.0.0 + - model_name: ipv4PrefixLength + mandatory: true + example: 8 test_prerequisites: | - variable "policy_object_feature_template_id" {} \ No newline at end of file + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_data_ipv6_prefix_list.yaml b/gen/definitions/profile_parcels/policy_object_data_ipv6_prefix_list.yaml index 28e21dcb..838e4925 100644 --- a/gen/definitions/profile_parcels/policy_object_data_ipv6_prefix_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_data_ipv6_prefix_list.yaml @@ -2,7 +2,7 @@ name: Policy Object Data IPv6 Prefix List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/data-ipv6-prefix minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,17 +12,17 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: ipv6Address - id: true - mandatory: true - example: 2001:db8:85a3::8a2e:370:7334 - - model_name: ipv6PrefixLength - mandatory: true - example: 64 + - model_name: ipv6Address + id: true + mandatory: true + example: 2001:db8:85a3::8a2e:370:7334 + - model_name: ipv6PrefixLength + mandatory: true + example: 64 test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_expanded_community_list.yaml b/gen/definitions/profile_parcels/policy_object_expanded_community_list.yaml index 76bf67cf..335328bb 100644 --- a/gen/definitions/profile_parcels/policy_object_expanded_community_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_expanded_community_list.yaml @@ -2,7 +2,7 @@ name: Policy Object Expanded Community List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/expanded-community minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,7 +12,7 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: expandedCommunityList tf_name: expanded_community_lists id: true @@ -20,4 +20,4 @@ attributes: example: abcd test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_extended_community_list.yaml b/gen/definitions/profile_parcels/policy_object_extended_community_list.yaml index 98e3cc62..7f2faf42 100644 --- a/gen/definitions/profile_parcels/policy_object_extended_community_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_extended_community_list.yaml @@ -2,7 +2,7 @@ name: Policy Object Extended Community List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/ext-community minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,15 +12,15 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: extCommunity - tf_name: extended_community - id: true - mandatory: true - example: "soo 10.0.0.1:30" + - model_name: extCommunity + tf_name: extended_community + id: true + mandatory: true + example: "soo 10.0.0.1:30" test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_ipv4_prefix_list.yaml b/gen/definitions/profile_parcels/policy_object_ipv4_prefix_list.yaml index 59e15c2f..18f6e5fd 100644 --- a/gen/definitions/profile_parcels/policy_object_ipv4_prefix_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_ipv4_prefix_list.yaml @@ -2,7 +2,7 @@ name: Policy Object IPv4 Prefix List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/prefix minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] parcel_type: policy_object attributes: - tf_name: feature_profile_id @@ -11,26 +11,26 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: ipv4Address - id: true - mandatory: true - example: 10.0.0.0 - minimum_test_value: '"10.0.0.0"' - - model_name: ipv4PrefixLength - id: true - mandatory: true - example: 8 - minimum_test_value: '8' - - model_name: leRangePrefixLength - tf_name: le - example: 24 - - model_name: geRangePrefixLength - tf_name: ge - example: 16 + - model_name: ipv4Address + id: true + mandatory: true + example: 10.0.0.0 + minimum_test_value: '"10.0.0.0"' + - model_name: ipv4PrefixLength + id: true + mandatory: true + example: 8 + minimum_test_value: "8" + - model_name: leRangePrefixLength + tf_name: le + example: 24 + - model_name: geRangePrefixLength + tf_name: ge + example: 16 test_prerequisites: | - variable "policy_object_feature_template_id" {} \ No newline at end of file + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_ipv6_prefix_list.yaml b/gen/definitions/profile_parcels/policy_object_ipv6_prefix_list.yaml index f07ee656..7b4a7d78 100644 --- a/gen/definitions/profile_parcels/policy_object_ipv6_prefix_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_ipv6_prefix_list.yaml @@ -2,7 +2,7 @@ name: Policy Object IPv6 Prefix List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/ipv6-prefix minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] parcel_type: policy_object attributes: - tf_name: feature_profile_id @@ -11,26 +11,26 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: ipv6Address - id: true - mandatory: true - example: 2001:db8:85a3::8a2e:370:7334 - minimum_test_value: '"2001:db8:85a3::8a2e:370:7334"' - - model_name: ipv6PrefixLength - id: true - mandatory: true - example: 64 - minimum_test_value: '64' - - model_name: leRangePrefixLength - tf_name: le - example: 100 - - model_name: geRangePrefixLength - tf_name: ge - example: 70 + - model_name: ipv6Address + id: true + mandatory: true + example: 2001:db8:85a3::8a2e:370:7334 + minimum_test_value: '"2001:db8:85a3::8a2e:370:7334"' + - model_name: ipv6PrefixLength + id: true + mandatory: true + example: 64 + minimum_test_value: "64" + - model_name: leRangePrefixLength + tf_name: le + example: 100 + - model_name: geRangePrefixLength + tf_name: ge + example: 70 test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_mirror.yaml b/gen/definitions/profile_parcels/policy_object_mirror.yaml index 6c2e4979..648af3fe 100644 --- a/gen/definitions/profile_parcels/policy_object_mirror.yaml +++ b/gen/definitions/profile_parcels/policy_object_mirror.yaml @@ -2,7 +2,7 @@ name: Policy Object Mirror rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/mirror minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,20 +12,20 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: remoteDestIp - tf_name: remote_destination_ip - id: true - mandatory: true - example: 10.0.0.1 - - model_name: sourceIp - tf_name: source_ip - id: true - mandatory: true - example: 10.0.0.2 + - model_name: remoteDestIp + tf_name: remote_destination_ip + id: true + mandatory: true + example: 10.0.0.1 + - model_name: sourceIp + tf_name: source_ip + id: true + mandatory: true + example: 10.0.0.2 test_prerequisites: | - variable "policy_object_feature_template_id" {} \ No newline at end of file + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_policer.yaml b/gen/definitions/profile_parcels/policy_object_policer.yaml index 322dc078..2017ea72 100644 --- a/gen/definitions/profile_parcels/policy_object_policer.yaml +++ b/gen/definitions/profile_parcels/policy_object_policer.yaml @@ -2,7 +2,7 @@ name: Policy Object Policer rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/policer minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,25 +12,25 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: burst - tf_name: burst_bytes - id: true - mandatory: true - example: 56500 - - model_name: exceed - tf_name: exceed_action - id: true - mandatory: true - example: remark - - model_name: rate - tf_name: rate_bps - id: true - mandatory: true - example: 60000 + - model_name: burst + tf_name: burst_bytes + id: true + mandatory: true + example: 56500 + - model_name: exceed + tf_name: exceed_action + id: true + mandatory: true + example: remark + - model_name: rate + tf_name: rate_bps + id: true + mandatory: true + example: 60000 test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/gen/definitions/profile_parcels/policy_object_tloc_list.yaml b/gen/definitions/profile_parcels/policy_object_tloc_list.yaml index f6a1a855..93c58e72 100644 --- a/gen/definitions/profile_parcels/policy_object_tloc_list.yaml +++ b/gen/definitions/profile_parcels/policy_object_tloc_list.yaml @@ -2,7 +2,7 @@ name: Policy Object TLOC List rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/tloc minimum_version: 20.12.0 -test_tags: [SDWAN_2012, TF_VAR_policy_object_feature_template_id] +test_tags: [SDWAN_2012] skip_minimum_test: true parcel_type: policy_object attributes: @@ -12,24 +12,24 @@ attributes: mandatory: true description: Feature Profile ID example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac - test_value: var.policy_object_feature_template_id + test_value: data.sdwan_policy_object_feature_profile.test.id - model_name: entries mandatory: true attributes: - - model_name: tloc - tf_name: tloc_ip - id: true - mandatory: true - example: 10.0.0.0 - - model_name: color - mandatory: true - example: 3g - - model_name: encap - tf_name: encapsulation - mandatory: true - example: gre - - model_name: preference - example: 33 + - model_name: tloc + tf_name: tloc_ip + id: true + mandatory: true + example: 10.0.0.0 + - model_name: color + mandatory: true + example: 3g + - model_name: encap + tf_name: encapsulation + mandatory: true + example: gre + - model_name: preference + example: 33 test_prerequisites: | - variable "policy_object_feature_template_id" {} + data "sdwan_policy_object_feature_profile" "test" {} diff --git a/internal/provider/data_source_sdwan_policy_object_class_map_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_class_map_profile_parcel_test.go index 6125db90..b45d498a 100644 --- a/internal/provider/data_source_sdwan_policy_object_class_map_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_class_map_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectClassMapProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_class_map.test", "entries.0.queue", "0")) @@ -50,7 +50,8 @@ func TestAccDataSourceSdwanPolicyObjectClassMapProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectClassMapPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -60,7 +61,7 @@ func testAccDataSourceSdwanPolicyObjectClassMapProfileParcelConfig() string { config := `resource "sdwan_policy_object_class_map" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` queue = "0"` + "\n" config += ` }]` + "\n" @@ -69,7 +70,7 @@ func testAccDataSourceSdwanPolicyObjectClassMapProfileParcelConfig() string { config += ` data "sdwan_policy_object_class_map" "test" { id = sdwan_policy_object_class_map.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_color_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_color_list_profile_parcel_test.go index 9e6f0914..17fcf1d1 100644 --- a/internal/provider/data_source_sdwan_policy_object_color_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_color_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectColorListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_color_list.test", "entries.0.color", "blue")) @@ -50,7 +50,8 @@ func TestAccDataSourceSdwanPolicyObjectColorListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectColorListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -60,7 +61,7 @@ func testAccDataSourceSdwanPolicyObjectColorListProfileParcelConfig() string { config := `resource "sdwan_policy_object_color_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` color = "blue"` + "\n" config += ` }]` + "\n" @@ -69,7 +70,7 @@ func testAccDataSourceSdwanPolicyObjectColorListProfileParcelConfig() string { config += ` data "sdwan_policy_object_color_list" "test" { id = sdwan_policy_object_color_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go index 48b09593..2272387b 100644 --- a/internal/provider/data_source_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectDataIPv4PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_data_ipv4_prefix_list.test", "entries.0.ipv4_address", "10.0.0.0")) @@ -51,7 +51,8 @@ func TestAccDataSourceSdwanPolicyObjectDataIPv4PrefixListProfileParcel(t *testin // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectDataIPv4PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -61,7 +62,7 @@ func testAccDataSourceSdwanPolicyObjectDataIPv4PrefixListProfileParcelConfig() s config := `resource "sdwan_policy_object_data_ipv4_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv4_address = "10.0.0.0"` + "\n" config += ` ipv4_prefix_length = 8` + "\n" @@ -71,7 +72,7 @@ func testAccDataSourceSdwanPolicyObjectDataIPv4PrefixListProfileParcelConfig() s config += ` data "sdwan_policy_object_data_ipv4_prefix_list" "test" { id = sdwan_policy_object_data_ipv4_prefix_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go index 8e79533d..e00d29d2 100644 --- a/internal/provider/data_source_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectDataIPv6PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_data_ipv6_prefix_list.test", "entries.0.ipv6_address", "2001:db8:85a3::8a2e:370:7334")) @@ -51,7 +51,7 @@ func TestAccDataSourceSdwanPolicyObjectDataIPv6PrefixListProfileParcel(t *testin // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectDataIPv6PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -62,7 +62,7 @@ func testAccDataSourceSdwanPolicyObjectDataIPv6PrefixListProfileParcelConfig() s config := `resource "sdwan_policy_object_data_ipv6_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv6_address = "2001:db8:85a3::8a2e:370:7334"` + "\n" config += ` ipv6_prefix_length = 64` + "\n" @@ -72,7 +72,7 @@ func testAccDataSourceSdwanPolicyObjectDataIPv6PrefixListProfileParcelConfig() s config += ` data "sdwan_policy_object_data_ipv6_prefix_list" "test" { id = sdwan_policy_object_data_ipv6_prefix_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_expanded_community_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_expanded_community_list_profile_parcel_test.go index 77f7a9c8..97a9b3c1 100644 --- a/internal/provider/data_source_sdwan_policy_object_expanded_community_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_expanded_community_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectExpandedCommunityListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc resource.Test(t, resource.TestCase{ @@ -49,7 +49,7 @@ func TestAccDataSourceSdwanPolicyObjectExpandedCommunityListProfileParcel(t *tes // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectExpandedCommunityListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -60,14 +60,14 @@ func testAccDataSourceSdwanPolicyObjectExpandedCommunityListProfileParcelConfig( config := `resource "sdwan_policy_object_expanded_community_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` expanded_community_lists = ["abcd"]` + "\n" config += `}` + "\n" config += ` data "sdwan_policy_object_expanded_community_list" "test" { id = sdwan_policy_object_expanded_community_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_extended_community_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_extended_community_list_profile_parcel_test.go index adcea832..7311f87e 100644 --- a/internal/provider/data_source_sdwan_policy_object_extended_community_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_extended_community_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectExtendedCommunityListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_extended_community_list.test", "entries.0.extended_community", "soo 10.0.0.1:30")) @@ -50,7 +50,7 @@ func TestAccDataSourceSdwanPolicyObjectExtendedCommunityListProfileParcel(t *tes // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectExtendedCommunityListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -61,7 +61,7 @@ func testAccDataSourceSdwanPolicyObjectExtendedCommunityListProfileParcelConfig( config := `resource "sdwan_policy_object_extended_community_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` extended_community = "soo 10.0.0.1:30"` + "\n" config += ` }]` + "\n" @@ -70,7 +70,7 @@ func testAccDataSourceSdwanPolicyObjectExtendedCommunityListProfileParcelConfig( config += ` data "sdwan_policy_object_extended_community_list" "test" { id = sdwan_policy_object_extended_community_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_feature_profile.go b/internal/provider/data_source_sdwan_policy_object_feature_profile.go index 2ee7d13a..458b4062 100644 --- a/internal/provider/data_source_sdwan_policy_object_feature_profile.go +++ b/internal/provider/data_source_sdwan_policy_object_feature_profile.go @@ -21,18 +21,16 @@ package provider import ( "context" "fmt" - "net/url" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-sdwan" ) // End of section. //template:end imports -// Section below is generated&owned by "gen/generator.go". //template:begin model - // Ensure the implementation satisfies the expected interfaces. var ( _ datasource.DataSource = &PolicyObjectFeatureProfileDataSource{} @@ -59,7 +57,7 @@ func (d *PolicyObjectFeatureProfileDataSource) Schema(ctx context.Context, req d Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "The id of the object", - Required: true, + Computed: true, }, "name": schema.StringAttribute{ MarkdownDescription: "The name of the policy object feature profile", @@ -81,9 +79,6 @@ func (d *PolicyObjectFeatureProfileDataSource) Configure(_ context.Context, req d.client = req.ProviderData.(*SdwanProviderData).Client } -// End of section. //template:end model - -// Section below is generated&owned by "gen/generator.go". //template:begin read func (d *PolicyObjectFeatureProfileDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var config PolicyObjectFeatureProfile @@ -94,20 +89,21 @@ func (d *PolicyObjectFeatureProfileDataSource) Read(ctx context.Context, req dat return } - tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", "Policy object feature profile")) - res, err := d.client.Get(config.getPath() + url.QueryEscape(config.Id.ValueString())) + res, err := d.client.Get(config.getPath()) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) return } - config.fromBody(ctx, res) + if len(res.Array()) > 0 { + config.fromBody(ctx, res.Array()[0]) + config.Id = types.StringValue(res.Array()[0].Get("profileId").String()) + } - tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", "Policy object feature profile")) diags = resp.State.Set(ctx, &config) resp.Diagnostics.Append(diags...) } - -// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_policy_object_feature_profile_test.go b/internal/provider/data_source_sdwan_policy_object_feature_profile_test.go index 1497a2a2..91ff8f5d 100644 --- a/internal/provider/data_source_sdwan_policy_object_feature_profile_test.go +++ b/internal/provider/data_source_sdwan_policy_object_feature_profile_test.go @@ -52,7 +52,6 @@ func TestAccDataSourceSdwanPolicyObjectFeatureProfile(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites // End of section. //template:end testPrerequisites -// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig func testAccDataSourceSdwanPolicyObjectFeatureProfileConfig() string { config := "" config += `resource "sdwan_policy_object_feature_profile" "test" {` + "\n" @@ -62,10 +61,8 @@ func testAccDataSourceSdwanPolicyObjectFeatureProfileConfig() string { config += ` data "sdwan_policy_object_feature_profile" "test" { - id = sdwan_policy_object_feature_profile.test.id + depends_on = [sdwan_policy_object_feature_profile.test] } ` return config } - -// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go index 869b757a..a7e4151e 100644 --- a/internal/provider/data_source_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectIPv4PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_ipv4_prefix_list.test", "entries.0.ipv4_address", "10.0.0.0")) @@ -53,7 +53,8 @@ func TestAccDataSourceSdwanPolicyObjectIPv4PrefixListProfileParcel(t *testing.T) // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectIPv4PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -63,7 +64,7 @@ func testAccDataSourceSdwanPolicyObjectIPv4PrefixListProfileParcelConfig() strin config := `resource "sdwan_policy_object_ipv4_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv4_address = "10.0.0.0"` + "\n" config += ` ipv4_prefix_length = 8` + "\n" @@ -75,7 +76,7 @@ func testAccDataSourceSdwanPolicyObjectIPv4PrefixListProfileParcelConfig() strin config += ` data "sdwan_policy_object_ipv4_prefix_list" "test" { id = sdwan_policy_object_ipv4_prefix_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go index d13da44a..80a31cd8 100644 --- a/internal/provider/data_source_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectIPv6PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_ipv6_prefix_list.test", "entries.0.ipv6_address", "2001:db8:85a3::8a2e:370:7334")) @@ -53,7 +53,7 @@ func TestAccDataSourceSdwanPolicyObjectIPv6PrefixListProfileParcel(t *testing.T) // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectIPv6PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -64,7 +64,7 @@ func testAccDataSourceSdwanPolicyObjectIPv6PrefixListProfileParcelConfig() strin config := `resource "sdwan_policy_object_ipv6_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv6_address = "2001:db8:85a3::8a2e:370:7334"` + "\n" config += ` ipv6_prefix_length = 64` + "\n" @@ -76,7 +76,7 @@ func testAccDataSourceSdwanPolicyObjectIPv6PrefixListProfileParcelConfig() strin config += ` data "sdwan_policy_object_ipv6_prefix_list" "test" { id = sdwan_policy_object_ipv6_prefix_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_mirror_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_mirror_profile_parcel_test.go index 6a816600..05f09375 100644 --- a/internal/provider/data_source_sdwan_policy_object_mirror_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_mirror_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectMirrorProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_mirror.test", "entries.0.remote_destination_ip", "10.0.0.1")) @@ -51,7 +51,8 @@ func TestAccDataSourceSdwanPolicyObjectMirrorProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectMirrorPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -61,7 +62,7 @@ func testAccDataSourceSdwanPolicyObjectMirrorProfileParcelConfig() string { config := `resource "sdwan_policy_object_mirror" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` remote_destination_ip = "10.0.0.1"` + "\n" config += ` source_ip = "10.0.0.2"` + "\n" @@ -71,7 +72,7 @@ func testAccDataSourceSdwanPolicyObjectMirrorProfileParcelConfig() string { config += ` data "sdwan_policy_object_mirror" "test" { id = sdwan_policy_object_mirror.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_policer_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_policer_profile_parcel_test.go index d463e165..92bb3a98 100644 --- a/internal/provider/data_source_sdwan_policy_object_policer_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_policer_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectPolicerProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_policer.test", "entries.0.burst_bytes", "56500")) @@ -52,7 +52,7 @@ func TestAccDataSourceSdwanPolicyObjectPolicerProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectPolicerPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -63,7 +63,7 @@ func testAccDataSourceSdwanPolicyObjectPolicerProfileParcelConfig() string { config := `resource "sdwan_policy_object_policer" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` burst_bytes = 56500` + "\n" config += ` exceed_action = "remark"` + "\n" @@ -74,7 +74,7 @@ func testAccDataSourceSdwanPolicyObjectPolicerProfileParcelConfig() string { config += ` data "sdwan_policy_object_policer" "test" { id = sdwan_policy_object_policer.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/data_source_sdwan_policy_object_tloc_list_profile_parcel_test.go b/internal/provider/data_source_sdwan_policy_object_tloc_list_profile_parcel_test.go index 4d6c0a74..e272c18c 100644 --- a/internal/provider/data_source_sdwan_policy_object_tloc_list_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_policy_object_tloc_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource func TestAccDataSourceSdwanPolicyObjectTLOCListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_tloc_list.test", "entries.0.tloc_ip", "10.0.0.0")) @@ -53,7 +53,7 @@ func TestAccDataSourceSdwanPolicyObjectTLOCListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccDataSourceSdwanPolicyObjectTLOCListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -64,7 +64,7 @@ func testAccDataSourceSdwanPolicyObjectTLOCListProfileParcelConfig() string { config := `resource "sdwan_policy_object_tloc_list" "test" {` + "\n" config += ` name = "TF_TEST"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` tloc_ip = "10.0.0.0"` + "\n" config += ` color = "3g"` + "\n" @@ -76,7 +76,7 @@ func testAccDataSourceSdwanPolicyObjectTLOCListProfileParcelConfig() string { config += ` data "sdwan_policy_object_tloc_list" "test" { id = sdwan_policy_object_tloc_list.test.id - feature_profile_id = var.policy_object_feature_template_id + feature_profile_id = data.sdwan_policy_object_feature_profile.test.id } ` return config diff --git a/internal/provider/resource_sdwan_policy_object_class_map_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_class_map_profile_parcel_test.go index 2d4eae9a..3e039ba9 100644 --- a/internal/provider/resource_sdwan_policy_object_class_map_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_class_map_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectClassMapProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_class_map.test", "entries.0.queue", "0")) @@ -51,7 +51,8 @@ func TestAccSdwanPolicyObjectClassMapProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectClassMapPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -65,7 +66,7 @@ func testAccSdwanPolicyObjectClassMapProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_class_map" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` queue = "0"` + "\n" config += ` }]` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_color_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_color_list_profile_parcel_test.go index 00e849f5..381435c1 100644 --- a/internal/provider/resource_sdwan_policy_object_color_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_color_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectColorListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_color_list.test", "entries.0.color", "blue")) @@ -51,7 +51,8 @@ func TestAccSdwanPolicyObjectColorListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectColorListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -65,7 +66,7 @@ func testAccSdwanPolicyObjectColorListProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_color_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` color = "blue"` + "\n" config += ` }]` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go index 3ce5850c..cd5f20fe 100644 --- a/internal/provider/resource_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_data_ipv4_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectDataIPv4PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_data_ipv4_prefix_list.test", "entries.0.ipv4_address", "10.0.0.0")) @@ -52,7 +52,8 @@ func TestAccSdwanPolicyObjectDataIPv4PrefixListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectDataIPv4PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -66,7 +67,7 @@ func testAccSdwanPolicyObjectDataIPv4PrefixListProfileParcelConfig_all() string config := `resource "sdwan_policy_object_data_ipv4_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv4_address = "10.0.0.0"` + "\n" config += ` ipv4_prefix_length = 8` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go index 66722f2f..3864e4b9 100644 --- a/internal/provider/resource_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_data_ipv6_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectDataIPv6PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_data_ipv6_prefix_list.test", "entries.0.ipv6_address", "2001:db8:85a3::8a2e:370:7334")) @@ -52,7 +52,7 @@ func TestAccSdwanPolicyObjectDataIPv6PrefixListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectDataIPv6PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -67,7 +67,7 @@ func testAccSdwanPolicyObjectDataIPv6PrefixListProfileParcelConfig_all() string config := `resource "sdwan_policy_object_data_ipv6_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv6_address = "2001:db8:85a3::8a2e:370:7334"` + "\n" config += ` ipv6_prefix_length = 64` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_expanded_community_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_expanded_community_list_profile_parcel_test.go index 946e3a20..8dba264a 100644 --- a/internal/provider/resource_sdwan_policy_object_expanded_community_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_expanded_community_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectExpandedCommunityListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc resource.Test(t, resource.TestCase{ @@ -50,7 +50,7 @@ func TestAccSdwanPolicyObjectExpandedCommunityListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectExpandedCommunityListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -65,7 +65,7 @@ func testAccSdwanPolicyObjectExpandedCommunityListProfileParcelConfig_all() stri config := `resource "sdwan_policy_object_expanded_community_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` expanded_community_lists = ["abcd"]` + "\n" config += `}` + "\n" return config diff --git a/internal/provider/resource_sdwan_policy_object_extended_community_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_extended_community_list_profile_parcel_test.go index 4552fffd..dee7bb90 100644 --- a/internal/provider/resource_sdwan_policy_object_extended_community_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_extended_community_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectExtendedCommunityListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_extended_community_list.test", "entries.0.extended_community", "soo 10.0.0.1:30")) @@ -51,7 +51,7 @@ func TestAccSdwanPolicyObjectExtendedCommunityListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectExtendedCommunityListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -66,7 +66,7 @@ func testAccSdwanPolicyObjectExtendedCommunityListProfileParcelConfig_all() stri config := `resource "sdwan_policy_object_extended_community_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` extended_community = "soo 10.0.0.1:30"` + "\n" config += ` }]` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_feature_profile.go b/internal/provider/resource_sdwan_policy_object_feature_profile.go index b088bd1d..f1ec28c4 100644 --- a/internal/provider/resource_sdwan_policy_object_feature_profile.go +++ b/internal/provider/resource_sdwan_policy_object_feature_profile.go @@ -60,7 +60,7 @@ func (r *PolicyObjectFeatureProfileResource) Metadata(ctx context.Context, req r func (r *PolicyObjectFeatureProfileResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: helpers.NewAttributeDescription("This resource can manage a Policy Object Feature Profile .").String, + MarkdownDescription: helpers.NewAttributeDescription("SD-WAN manager supports only a single policy object feature profile to be configured. This resource will therefore either create a new one if none exists or update the existing one.").String, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ @@ -93,7 +93,6 @@ func (r *PolicyObjectFeatureProfileResource) Configure(_ context.Context, req re // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create func (r *PolicyObjectFeatureProfileResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan PolicyObjectFeatureProfile @@ -109,12 +108,26 @@ func (r *PolicyObjectFeatureProfileResource) Create(ctx context.Context, req res // Create object body := plan.toBody(ctx) - res, err := r.client.Post(plan.getPath(), body) + res, err := r.client.Get(plan.getPath()) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) return } - plan.Id = types.StringValue(res.Get("id").String()) + if len(res.Array()) > 0 { + plan.Id = types.StringValue(res.Array()[0].Get("profileId").String()) + res, err = r.client.Put(plan.getPath()+url.QueryEscape(plan.Id.ValueString()), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + } else { + res, err = r.client.Post(plan.getPath(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String())) + return + } + plan.Id = types.StringValue(res.Get("id").String()) + } tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) @@ -122,8 +135,6 @@ func (r *PolicyObjectFeatureProfileResource) Create(ctx context.Context, req res resp.Diagnostics.Append(diags...) } -// End of section. //template:end create - // Section below is generated&owned by "gen/generator.go". //template:begin read func (r *PolicyObjectFeatureProfileResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state PolicyObjectFeatureProfile @@ -202,7 +213,6 @@ func (r *PolicyObjectFeatureProfileResource) Update(ctx context.Context, req res // End of section. //template:end update -// Section below is generated&owned by "gen/generator.go". //template:begin delete func (r *PolicyObjectFeatureProfileResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state PolicyObjectFeatureProfile @@ -215,19 +225,11 @@ func (r *PolicyObjectFeatureProfileResource) Delete(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Name.ValueString())) - res, err := r.client.Delete(state.getPath() + url.QueryEscape(state.Id.ValueString())) - if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (DELETE), got error: %s, %s", err, res.String())) - return - } - tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Name.ValueString())) resp.State.RemoveResource(ctx) } -// End of section. //template:end delete - // Section below is generated&owned by "gen/generator.go". //template:begin import func (r *PolicyObjectFeatureProfileResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) diff --git a/internal/provider/resource_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go index 9ad859f1..676e1fb3 100644 --- a/internal/provider/resource_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_ipv4_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectIPv4PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_ipv4_prefix_list.test", "entries.0.ipv4_address", "10.0.0.0")) @@ -56,7 +56,8 @@ func TestAccSdwanPolicyObjectIPv4PrefixListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectIPv4PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -66,7 +67,7 @@ func testAccSdwanPolicyObjectIPv4PrefixListProfileParcelConfig_minimum() string config := `resource "sdwan_policy_object_ipv4_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_MIN"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv4_address = "10.0.0.0"` + "\n" config += ` ipv4_prefix_length = 8` + "\n" @@ -84,7 +85,7 @@ func testAccSdwanPolicyObjectIPv4PrefixListProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_ipv4_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv4_address = "10.0.0.0"` + "\n" config += ` ipv4_prefix_length = 8` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go index 077712ee..584458b9 100644 --- a/internal/provider/resource_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_ipv6_prefix_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectIPv6PrefixListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_ipv6_prefix_list.test", "entries.0.ipv6_address", "2001:db8:85a3::8a2e:370:7334")) @@ -56,7 +56,7 @@ func TestAccSdwanPolicyObjectIPv6PrefixListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectIPv6PrefixListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -67,7 +67,7 @@ func testAccSdwanPolicyObjectIPv6PrefixListProfileParcelConfig_minimum() string config := `resource "sdwan_policy_object_ipv6_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_MIN"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv6_address = "2001:db8:85a3::8a2e:370:7334"` + "\n" config += ` ipv6_prefix_length = 64` + "\n" @@ -85,7 +85,7 @@ func testAccSdwanPolicyObjectIPv6PrefixListProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_ipv6_prefix_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` ipv6_address = "2001:db8:85a3::8a2e:370:7334"` + "\n" config += ` ipv6_prefix_length = 64` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_mirror_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_mirror_profile_parcel_test.go index 52f32a19..6a686da5 100644 --- a/internal/provider/resource_sdwan_policy_object_mirror_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_mirror_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectMirrorProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_mirror.test", "entries.0.remote_destination_ip", "10.0.0.1")) @@ -52,7 +52,8 @@ func TestAccSdwanPolicyObjectMirrorProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectMirrorPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} + ` // End of section. //template:end testPrerequisites @@ -66,7 +67,7 @@ func testAccSdwanPolicyObjectMirrorProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_mirror" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` remote_destination_ip = "10.0.0.1"` + "\n" config += ` source_ip = "10.0.0.2"` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_policer_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_policer_profile_parcel_test.go index f1527e52..cba7808a 100644 --- a/internal/provider/resource_sdwan_policy_object_policer_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_policer_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectPolicerProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_policer.test", "entries.0.burst_bytes", "56500")) @@ -53,7 +53,7 @@ func TestAccSdwanPolicyObjectPolicerProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectPolicerPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -68,7 +68,7 @@ func testAccSdwanPolicyObjectPolicerProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_policer" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` burst_bytes = 56500` + "\n" config += ` exceed_action = "remark"` + "\n" diff --git a/internal/provider/resource_sdwan_policy_object_tloc_list_profile_parcel_test.go b/internal/provider/resource_sdwan_policy_object_tloc_list_profile_parcel_test.go index 8794b06a..1237e3f3 100644 --- a/internal/provider/resource_sdwan_policy_object_tloc_list_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_policy_object_tloc_list_profile_parcel_test.go @@ -29,8 +29,8 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin testAcc func TestAccSdwanPolicyObjectTLOCListProfileParcel(t *testing.T) { - if os.Getenv("SDWAN_2012") == "" && os.Getenv("TF_VAR_policy_object_feature_template_id") == "" { - t.Skip("skipping test, set environment variable SDWAN_2012 or TF_VAR_policy_object_feature_template_id") + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("sdwan_policy_object_tloc_list.test", "entries.0.tloc_ip", "10.0.0.0")) @@ -54,7 +54,7 @@ func TestAccSdwanPolicyObjectTLOCListProfileParcel(t *testing.T) { // Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites const testAccSdwanPolicyObjectTLOCListPrerequisitesProfileParcelConfig = ` -variable "policy_object_feature_template_id" {} +data "sdwan_policy_object_feature_profile" "test" {} ` @@ -69,7 +69,7 @@ func testAccSdwanPolicyObjectTLOCListProfileParcelConfig_all() string { config := `resource "sdwan_policy_object_tloc_list" "test" {` + "\n" config += ` name = "TF_TEST_ALL"` + "\n" config += ` description = "Terraform integration test"` + "\n" - config += ` feature_profile_id = var.policy_object_feature_template_id` + "\n" + config += ` feature_profile_id = data.sdwan_policy_object_feature_profile.test.id` + "\n" config += ` entries = [{` + "\n" config += ` tloc_ip = "10.0.0.0"` + "\n" config += ` color = "3g"` + "\n"