From 6e1c88e6e72304113ca25ef0249cf73730876436 Mon Sep 17 00:00:00 2001 From: Sean Conroy <141843633+seconroy@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:54:58 +0100 Subject: [PATCH] Adds tracker profile parcels (#293) --- CHANGELOG.md | 6 + ...ice_object_tracker_group_profile_parcel.md | 46 ++ .../service_object_tracker_profile_parcel.md | 45 ++ .../service_tracker_group_profile_parcel.md | 44 ++ ...sport_ipv6_tracker_group_profile_parcel.md | 46 ++ .../transport_tracker_group_profile_parcel.md | 44 ++ .../transport_tracker_profile_parcel.md | 52 ++ docs/guides/changelog.md | 6 + ...ice_object_tracker_group_profile_parcel.md | 70 ++ .../service_object_tracker_profile_parcel.md | 67 ++ .../service_tracker_group_profile_parcel.md | 66 ++ ...sport_ipv6_tracker_group_profile_parcel.md | 69 ++ .../transport_tracker_group_profile_parcel.md | 66 ++ .../transport_tracker_profile_parcel.md | 85 +++ .../data-source.tf | 4 + .../data-source.tf | 4 + .../data-source.tf | 4 + .../data-source.tf | 4 + .../data-source.tf | 4 + .../data-source.tf | 4 + .../import.sh | 1 + .../resource.tf | 12 + .../import.sh | 1 + .../resource.tf | 8 + .../import.sh | 1 + .../resource.tf | 11 + .../import.sh | 1 + .../resource.tf | 12 + .../import.sh | 1 + .../resource.tf | 11 + .../import.sh | 1 + .../resource.tf | 14 + .../service_object_tracker.yaml | 39 ++ .../service_object_tracker_group.yaml | 56 ++ .../service_tracker_group.yaml | 68 ++ .../transport_ipv6_tracker_group.yaml | 68 ++ .../profile_parcels/transport_tracker.yaml | 38 ++ .../transport_tracker_group.yaml | 64 ++ gen/generator.go | 2 + .../service_object_tracker.json | 419 ++++++++++++ .../service_object_tracker_group.json | 221 +++++++ .../service_tracker_group.json | 199 ++++++ .../transport_ipv6_tracker_group.json | 247 +++++++ .../profile_parcels/transport_tracker.json | 608 ++++++++++++++++++ .../transport_tracker_group.json | 199 ++++++ gen/schema/schema.yaml | 2 + .../profile_parcels/data_source_test.go | 32 +- .../profile_parcels/resource_test.go | 40 +- ...ice_object_tracker_group_profile_parcel.go | 150 +++++ ...bject_tracker_group_profile_parcel_test.go | 103 +++ ...n_service_object_tracker_profile_parcel.go | 166 +++++ ...vice_object_tracker_profile_parcel_test.go | 83 +++ ...an_service_tracker_group_profile_parcel.go | 142 ++++ ...rvice_tracker_group_profile_parcel_test.go | 118 ++++ ...sport_ipv6_tracker_group_profile_parcel.go | 150 +++++ ..._ipv6_tracker_group_profile_parcel_test.go | 116 ++++ ..._transport_tracker_group_profile_parcel.go | 142 ++++ ...sport_tracker_group_profile_parcel_test.go | 114 ++++ ..._sdwan_transport_tracker_profile_parcel.go | 194 ++++++ ...n_transport_tracker_profile_parcel_test.go | 95 +++ ...ice_object_tracker_group_profile_parcel.go | 246 +++++++ ...n_service_object_tracker_profile_parcel.go | 313 +++++++++ ...an_service_tracker_group_profile_parcel.go | 210 ++++++ ...sport_ipv6_tracker_group_profile_parcel.go | 246 +++++++ ..._transport_tracker_group_profile_parcel.go | 210 ++++++ ..._sdwan_transport_tracker_profile_parcel.go | 442 +++++++++++++ internal/provider/provider.go | 12 + ...ice_object_tracker_group_profile_parcel.go | 281 ++++++++ ...bject_tracker_group_profile_parcel_test.go | 101 +++ ...n_service_object_tracker_profile_parcel.go | 301 +++++++++ ...vice_object_tracker_profile_parcel_test.go | 94 +++ ...an_service_tracker_group_profile_parcel.go | 269 ++++++++ ...rvice_tracker_group_profile_parcel_test.go | 116 ++++ ...sport_ipv6_tracker_group_profile_parcel.go | 280 ++++++++ ..._ipv6_tracker_group_profile_parcel_test.go | 114 ++++ ..._transport_tracker_group_profile_parcel.go | 269 ++++++++ ...sport_tracker_group_profile_parcel_test.go | 112 ++++ ..._sdwan_transport_tracker_profile_parcel.go | 341 ++++++++++ ...n_transport_tracker_profile_parcel_test.go | 104 +++ templates/guides/changelog.md.tmpl | 6 + 80 files changed, 8740 insertions(+), 12 deletions(-) create mode 100644 docs/data-sources/service_object_tracker_group_profile_parcel.md create mode 100644 docs/data-sources/service_object_tracker_profile_parcel.md create mode 100644 docs/data-sources/service_tracker_group_profile_parcel.md create mode 100644 docs/data-sources/transport_ipv6_tracker_group_profile_parcel.md create mode 100644 docs/data-sources/transport_tracker_group_profile_parcel.md create mode 100644 docs/data-sources/transport_tracker_profile_parcel.md create mode 100644 docs/resources/service_object_tracker_group_profile_parcel.md create mode 100644 docs/resources/service_object_tracker_profile_parcel.md create mode 100644 docs/resources/service_tracker_group_profile_parcel.md create mode 100644 docs/resources/transport_ipv6_tracker_group_profile_parcel.md create mode 100644 docs/resources/transport_tracker_group_profile_parcel.md create mode 100644 docs/resources/transport_tracker_profile_parcel.md create mode 100644 examples/data-sources/sdwan_service_object_tracker_group_profile_parcel/data-source.tf create mode 100644 examples/data-sources/sdwan_service_object_tracker_profile_parcel/data-source.tf create mode 100644 examples/data-sources/sdwan_service_tracker_group_profile_parcel/data-source.tf create mode 100644 examples/data-sources/sdwan_transport_ipv6_tracker_group_profile_parcel/data-source.tf create mode 100644 examples/data-sources/sdwan_transport_tracker_group_profile_parcel/data-source.tf create mode 100644 examples/data-sources/sdwan_transport_tracker_profile_parcel/data-source.tf create mode 100644 examples/resources/sdwan_service_object_tracker_group_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_service_object_tracker_group_profile_parcel/resource.tf create mode 100644 examples/resources/sdwan_service_object_tracker_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_service_object_tracker_profile_parcel/resource.tf create mode 100644 examples/resources/sdwan_service_tracker_group_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_service_tracker_group_profile_parcel/resource.tf create mode 100644 examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/resource.tf create mode 100644 examples/resources/sdwan_transport_tracker_group_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_transport_tracker_group_profile_parcel/resource.tf create mode 100644 examples/resources/sdwan_transport_tracker_profile_parcel/import.sh create mode 100644 examples/resources/sdwan_transport_tracker_profile_parcel/resource.tf create mode 100644 gen/definitions/profile_parcels/service_object_tracker.yaml create mode 100644 gen/definitions/profile_parcels/service_object_tracker_group.yaml create mode 100644 gen/definitions/profile_parcels/service_tracker_group.yaml create mode 100644 gen/definitions/profile_parcels/transport_ipv6_tracker_group.yaml create mode 100644 gen/definitions/profile_parcels/transport_tracker.yaml create mode 100644 gen/definitions/profile_parcels/transport_tracker_group.yaml create mode 100644 gen/models/profile_parcels/service_object_tracker.json create mode 100644 gen/models/profile_parcels/service_object_tracker_group.json create mode 100644 gen/models/profile_parcels/service_tracker_group.json create mode 100644 gen/models/profile_parcels/transport_ipv6_tracker_group.json create mode 100644 gen/models/profile_parcels/transport_tracker.json create mode 100644 gen/models/profile_parcels/transport_tracker_group.json create mode 100644 internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/data_source_sdwan_service_object_tracker_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_service_object_tracker_profile_parcel_test.go create mode 100644 internal/provider/data_source_sdwan_service_tracker_group_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_service_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/data_source_sdwan_transport_tracker_profile_parcel.go create mode 100644 internal/provider/data_source_sdwan_transport_tracker_profile_parcel_test.go create mode 100644 internal/provider/model_sdwan_service_object_tracker_group_profile_parcel.go create mode 100644 internal/provider/model_sdwan_service_object_tracker_profile_parcel.go create mode 100644 internal/provider/model_sdwan_service_tracker_group_profile_parcel.go create mode 100644 internal/provider/model_sdwan_transport_ipv6_tracker_group_profile_parcel.go create mode 100644 internal/provider/model_sdwan_transport_tracker_group_profile_parcel.go create mode 100644 internal/provider/model_sdwan_transport_tracker_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/resource_sdwan_service_object_tracker_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_service_object_tracker_profile_parcel_test.go create mode 100644 internal/provider/resource_sdwan_service_tracker_group_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_service_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/resource_sdwan_transport_tracker_group_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_transport_tracker_group_profile_parcel_test.go create mode 100644 internal/provider/resource_sdwan_transport_tracker_profile_parcel.go create mode 100644 internal/provider/resource_sdwan_transport_tracker_profile_parcel_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e2698286..c67e362b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ## 0.3.14 (unreleased) - Fix issue when reading deleted `sdwan_cli_config_profile_parcel` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/291) +- Add `sdwan_transport_tracker_group_profile_parcel` resource and data source +- Add `sdwan_transport_tracker_profile_parcel` resource and data source +- Add `sdwan_service_tracker_group_profile_parcel` resource and data source +- Add `sdwan_transport_ipv6_tracker_group_profile_parcel` resource and data source +- Add `sdwan_service_object_tracker_profile_parcel` resource and data source +- Add `sdwan_service_object_tracker_group_profile_parcel` resource and data source ## 0.3.13 diff --git a/docs/data-sources/service_object_tracker_group_profile_parcel.md b/docs/data-sources/service_object_tracker_group_profile_parcel.md new file mode 100644 index 00000000..6182ee16 --- /dev/null +++ b/docs/data-sources/service_object_tracker_group_profile_parcel.md @@ -0,0 +1,46 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_object_tracker_group_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Service Object Tracker Group profile parcel. +--- + +# sdwan_service_object_tracker_group_profile_parcel (Data Source) + +This data source can read the Service Object Tracker Group profile parcel. + +## Example Usage + +```terraform +data "sdwan_service_object_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `name` (String) The name of the profile parcel +- `object_tracker_id` (Number) Object ID +- `object_tracker_id_variable` (String) Variable name +- `reachable` (String) tracker ref list criteria boolean and or +- `reachable_variable` (String) Variable name +- `tracker_elements` (Attributes List) Group Tracks ID Refs (see [below for nested schema](#nestedatt--tracker_elements)) +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Read-Only: + +- `object_tracker_id` (String) diff --git a/docs/data-sources/service_object_tracker_profile_parcel.md b/docs/data-sources/service_object_tracker_profile_parcel.md new file mode 100644 index 00000000..1de87ec3 --- /dev/null +++ b/docs/data-sources/service_object_tracker_profile_parcel.md @@ -0,0 +1,45 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_object_tracker_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Service Object Tracker profile parcel. +--- + +# sdwan_service_object_tracker_profile_parcel (Data Source) + +This data source can read the Service Object Tracker profile parcel. + +## Example Usage + +```terraform +data "sdwan_service_object_tracker_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `interface` (String) interface name +- `interface_variable` (String) Variable name +- `name` (String) The name of the profile parcel +- `object_tracker_id` (Number) Object tracker ID +- `object_tracker_id_variable` (String) Variable name +- `object_tracker_type` (String) objectTrackerType:Interface SIG Route +- `route_ip` (String) IP address +- `route_ip_variable` (String) Variable name +- `route_mask` (String) IP mask +- `route_mask_variable` (String) Variable name +- `version` (Number) The version of the profile parcel +- `vpn` (Number) VPN +- `vpn_variable` (String) Variable name diff --git a/docs/data-sources/service_tracker_group_profile_parcel.md b/docs/data-sources/service_tracker_group_profile_parcel.md new file mode 100644 index 00000000..f6b07d9d --- /dev/null +++ b/docs/data-sources/service_tracker_group_profile_parcel.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_tracker_group_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Service Tracker Group profile parcel. +--- + +# sdwan_service_tracker_group_profile_parcel (Data Source) + +This data source can read the Service Tracker Group profile parcel. + +## Example Usage + +```terraform +data "sdwan_service_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `name` (String) The name of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) tracker parcel ref list (see [below for nested schema](#nestedatt--tracker_elements)) +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Read-Only: + +- `tracker_id` (String) diff --git a/docs/data-sources/transport_ipv6_tracker_group_profile_parcel.md b/docs/data-sources/transport_ipv6_tracker_group_profile_parcel.md new file mode 100644 index 00000000..a88d9348 --- /dev/null +++ b/docs/data-sources/transport_ipv6_tracker_group_profile_parcel.md @@ -0,0 +1,46 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_ipv6_tracker_group_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Transport IPv6 Tracker Group profile parcel. +--- + +# sdwan_transport_ipv6_tracker_group_profile_parcel (Data Source) + +This data source can read the Transport IPv6 Tracker Group profile parcel. + +## Example Usage + +```terraform +data "sdwan_transport_ipv6_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `name` (String) The name of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) trackers ref list (see [below for nested schema](#nestedatt--tracker_elements)) +- `tracker_name` (String) Tracker Name +- `tracker_name_variable` (String) Variable name +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Read-Only: + +- `tracker_id` (String) diff --git a/docs/data-sources/transport_tracker_group_profile_parcel.md b/docs/data-sources/transport_tracker_group_profile_parcel.md new file mode 100644 index 00000000..f09c5c30 --- /dev/null +++ b/docs/data-sources/transport_tracker_group_profile_parcel.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_tracker_group_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Transport Tracker Group profile parcel. +--- + +# sdwan_transport_tracker_group_profile_parcel (Data Source) + +This data source can read the Transport Tracker Group profile parcel. + +## Example Usage + +```terraform +data "sdwan_transport_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `name` (String) The name of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) tracker parcel ref list (see [below for nested schema](#nestedatt--tracker_elements)) +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Read-Only: + +- `tracker_id` (String) diff --git a/docs/data-sources/transport_tracker_profile_parcel.md b/docs/data-sources/transport_tracker_profile_parcel.md new file mode 100644 index 00000000..9115427d --- /dev/null +++ b/docs/data-sources/transport_tracker_profile_parcel.md @@ -0,0 +1,52 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_tracker_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Transport Tracker profile parcel. +--- + +# sdwan_transport_tracker_profile_parcel (Data Source) + +This data source can read the Transport Tracker profile parcel. + +## Example Usage + +```terraform +data "sdwan_transport_tracker_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `id` (String) The id of the profile parcel + +### Read-Only + +- `description` (String) The description of the profile parcel +- `endpoint_api_url` (String) API url of endpoint +- `endpoint_api_url_variable` (String) Variable name +- `endpoint_dns_name` (String) Endpoint DNS Name +- `endpoint_dns_name_variable` (String) Variable name +- `endpoint_ip` (String) Endpoint IP +- `endpoint_ip_variable` (String) Variable name +- `endpoint_tracker_type` (String) Endpoint Tracker Type +- `endpoint_tracker_type_variable` (String) Variable name +- `interval` (Number) Interval +- `interval_variable` (String) Variable name +- `multiplier` (Number) Multiplier +- `multiplier_variable` (String) Variable name +- `name` (String) The name of the profile parcel +- `threshold` (Number) Threshold +- `threshold_variable` (String) Variable name +- `tracker_name` (String) Tracker Name +- `tracker_name_variable` (String) Variable name +- `tracker_type` (String) Tracker Type +- `tracker_type_variable` (String) Variable name +- `version` (Number) The version of the profile parcel diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index c87e96ed..4b6b93d8 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -10,6 +10,12 @@ description: |- ## 0.3.14 (unreleased) - Fix issue when reading deleted `sdwan_cli_config_profile_parcel` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/291) +- Add `sdwan_transport_tracker_group_profile_parcel` resource and data source +- Add `sdwan_transport_tracker_profile_parcel` resource and data source +- Add `sdwan_service_tracker_group_profile_parcel` resource and data source +- Add `sdwan_transport_ipv6_tracker_group_profile_parcel` resource and data source +- Add `sdwan_service_object_tracker_profile_parcel` resource and data source +- Add `sdwan_service_object_tracker_group_profile_parcel` resource and data source ## 0.3.13 diff --git a/docs/resources/service_object_tracker_group_profile_parcel.md b/docs/resources/service_object_tracker_group_profile_parcel.md new file mode 100644 index 00000000..7bd9ff7d --- /dev/null +++ b/docs/resources/service_object_tracker_group_profile_parcel.md @@ -0,0 +1,70 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_object_tracker_group_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Service Object Tracker Group profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_service_object_tracker_group_profile_parcel (Resource) + +This resource can manage a Service Object Tracker Group profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_service_object_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + object_tracker_id = 10 + tracker_elements = [ + { + object_tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + reachable = "or" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel +- `object_tracker_id` (Number) Object ID + - Range: `1`-`1000` + +### Optional + +- `description` (String) The description of the profile parcel +- `object_tracker_id_variable` (String) Variable name +- `reachable` (String) tracker ref list criteria boolean and or + - Choices: `and`, `or` + - Default value: `or` +- `reachable_variable` (String) Variable name +- `tracker_elements` (Attributes List) Group Tracks ID Refs (see [below for nested schema](#nestedatt--tracker_elements)) + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Optional: + +- `object_tracker_id` (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_service_object_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/docs/resources/service_object_tracker_profile_parcel.md b/docs/resources/service_object_tracker_profile_parcel.md new file mode 100644 index 00000000..49678259 --- /dev/null +++ b/docs/resources/service_object_tracker_profile_parcel.md @@ -0,0 +1,67 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_object_tracker_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Service Object Tracker profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_service_object_tracker_profile_parcel (Resource) + +This resource can manage a Service Object Tracker profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_service_object_tracker_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + object_tracker_id = 10 + object_tracker_type = "Interface" + interface = "GigabitEthernet1" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel +- `object_tracker_id` (Number) Object tracker ID + - Range: `1`-`1000` +- `object_tracker_type` (String) objectTrackerType:Interface SIG Route + - Choices: `Interface`, `SIG`, `Route` + +### Optional + +- `description` (String) The description of the profile parcel +- `interface` (String) interface name +- `interface_variable` (String) Variable name +- `object_tracker_id_variable` (String) Variable name +- `route_ip` (String) IP address +- `route_ip_variable` (String) Variable name +- `route_mask` (String) IP mask + - Choices: `255.255.255.255`, `255.255.255.254`, `255.255.255.252`, `255.255.255.248`, `255.255.255.240`, `255.255.255.224`, `255.255.255.192`, `255.255.255.128`, `255.255.255.0`, `255.255.254.0`, `255.255.252.0`, `255.255.248.0`, `255.255.240.0`, `255.255.224.0`, `255.255.192.0`, `255.255.128.0`, `255.255.0.0`, `255.254.0.0`, `255.252.0.0`, `255.240.0.0`, `255.224.0.0`, `255.192.0.0`, `255.128.0.0`, `255.0.0.0`, `254.0.0.0`, `252.0.0.0`, `248.0.0.0`, `240.0.0.0`, `224.0.0.0`, `192.0.0.0`, `128.0.0.0`, `0.0.0.0` + - Default value: `0.0.0.0` +- `route_mask_variable` (String) Variable name +- `vpn` (Number) VPN + - Range: `0`-`65530` +- `vpn_variable` (String) Variable name + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_service_object_tracker_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/docs/resources/service_tracker_group_profile_parcel.md b/docs/resources/service_tracker_group_profile_parcel.md new file mode 100644 index 00000000..bca0a103 --- /dev/null +++ b/docs/resources/service_tracker_group_profile_parcel.md @@ -0,0 +1,66 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_service_tracker_group_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Service Tracker Group profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_service_tracker_group_profile_parcel (Resource) + +This resource can manage a Service Tracker Group profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_service_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel + +### Optional + +- `description` (String) The description of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or + - Choices: `and`, `or` + - Default value: `or` +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) tracker parcel ref list (see [below for nested schema](#nestedatt--tracker_elements)) + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Optional: + +- `tracker_id` (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_service_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/docs/resources/transport_ipv6_tracker_group_profile_parcel.md b/docs/resources/transport_ipv6_tracker_group_profile_parcel.md new file mode 100644 index 00000000..b785c30d --- /dev/null +++ b/docs/resources/transport_ipv6_tracker_group_profile_parcel.md @@ -0,0 +1,69 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_ipv6_tracker_group_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Transport IPv6 Tracker Group profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_transport_ipv6_tracker_group_profile_parcel (Resource) + +This resource can manage a Transport IPv6 Tracker Group profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_transport_ipv6_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_name = "TRACKER_GROUP_1" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel +- `tracker_name` (String) Tracker Name + +### Optional + +- `description` (String) The description of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or + - Choices: `and`, `or` + - Default value: `or` +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) trackers ref list (see [below for nested schema](#nestedatt--tracker_elements)) +- `tracker_name_variable` (String) Variable name + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Optional: + +- `tracker_id` (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_transport_ipv6_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/docs/resources/transport_tracker_group_profile_parcel.md b/docs/resources/transport_tracker_group_profile_parcel.md new file mode 100644 index 00000000..95c15ace --- /dev/null +++ b/docs/resources/transport_tracker_group_profile_parcel.md @@ -0,0 +1,66 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_tracker_group_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Transport Tracker Group profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_transport_tracker_group_profile_parcel (Resource) + +This resource can manage a Transport Tracker Group profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_transport_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel + +### Optional + +- `description` (String) The description of the profile parcel +- `tracker_boolean` (String) tracker ref list combine boolean and or + - Choices: `and`, `or` + - Default value: `or` +- `tracker_boolean_variable` (String) Variable name +- `tracker_elements` (Attributes List) tracker parcel ref list (see [below for nested schema](#nestedatt--tracker_elements)) + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `tracker_elements` + +Optional: + +- `tracker_id` (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_transport_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/docs/resources/transport_tracker_profile_parcel.md b/docs/resources/transport_tracker_profile_parcel.md new file mode 100644 index 00000000..cac28b7a --- /dev/null +++ b/docs/resources/transport_tracker_profile_parcel.md @@ -0,0 +1,85 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_transport_tracker_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Transport Tracker profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_transport_tracker_profile_parcel (Resource) + +This resource can manage a Transport Tracker profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_transport_tracker_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} +``` + + +## Schema + +### Required + +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel + +### Optional + +- `description` (String) The description of the profile parcel +- `endpoint_api_url` (String) API url of endpoint +- `endpoint_api_url_variable` (String) Variable name +- `endpoint_dns_name` (String) Endpoint DNS Name +- `endpoint_dns_name_variable` (String) Variable name +- `endpoint_ip` (String) Endpoint IP +- `endpoint_ip_variable` (String) Variable name +- `endpoint_tracker_type` (String) Endpoint Tracker Type + - Choices: `interface` + - Default value: `interface` +- `endpoint_tracker_type_variable` (String) Variable name +- `interval` (Number) Interval + - Range: `20`-`600` + - Default value: `60` +- `interval_variable` (String) Variable name +- `multiplier` (Number) Multiplier + - Range: `1`-`10` + - Default value: `3` +- `multiplier_variable` (String) Variable name +- `threshold` (Number) Threshold + - Range: `100`-`1000` + - Default value: `300` +- `threshold_variable` (String) Variable name +- `tracker_name` (String) Tracker Name +- `tracker_name_variable` (String) Variable name +- `tracker_type` (String) Tracker Type + - Choices: `endpoint`, `object` + - Default value: `endpoint` +- `tracker_type_variable` (String) Variable name + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_transport_tracker_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/examples/data-sources/sdwan_service_object_tracker_group_profile_parcel/data-source.tf b/examples/data-sources/sdwan_service_object_tracker_group_profile_parcel/data-source.tf new file mode 100644 index 00000000..09d8e3a0 --- /dev/null +++ b/examples/data-sources/sdwan_service_object_tracker_group_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_service_object_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/data-sources/sdwan_service_object_tracker_profile_parcel/data-source.tf b/examples/data-sources/sdwan_service_object_tracker_profile_parcel/data-source.tf new file mode 100644 index 00000000..3022c936 --- /dev/null +++ b/examples/data-sources/sdwan_service_object_tracker_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_service_object_tracker_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/data-sources/sdwan_service_tracker_group_profile_parcel/data-source.tf b/examples/data-sources/sdwan_service_tracker_group_profile_parcel/data-source.tf new file mode 100644 index 00000000..24f9f2ab --- /dev/null +++ b/examples/data-sources/sdwan_service_tracker_group_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_service_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/data-sources/sdwan_transport_ipv6_tracker_group_profile_parcel/data-source.tf b/examples/data-sources/sdwan_transport_ipv6_tracker_group_profile_parcel/data-source.tf new file mode 100644 index 00000000..21f1a376 --- /dev/null +++ b/examples/data-sources/sdwan_transport_ipv6_tracker_group_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_transport_ipv6_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/data-sources/sdwan_transport_tracker_group_profile_parcel/data-source.tf b/examples/data-sources/sdwan_transport_tracker_group_profile_parcel/data-source.tf new file mode 100644 index 00000000..9543cb3b --- /dev/null +++ b/examples/data-sources/sdwan_transport_tracker_group_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_transport_tracker_group_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/data-sources/sdwan_transport_tracker_profile_parcel/data-source.tf b/examples/data-sources/sdwan_transport_tracker_profile_parcel/data-source.tf new file mode 100644 index 00000000..fc31d4f7 --- /dev/null +++ b/examples/data-sources/sdwan_transport_tracker_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_transport_tracker_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/resources/sdwan_service_object_tracker_group_profile_parcel/import.sh b/examples/resources/sdwan_service_object_tracker_group_profile_parcel/import.sh new file mode 100644 index 00000000..3cf98ac8 --- /dev/null +++ b/examples/resources/sdwan_service_object_tracker_group_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_service_object_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_service_object_tracker_group_profile_parcel/resource.tf b/examples/resources/sdwan_service_object_tracker_group_profile_parcel/resource.tf new file mode 100644 index 00000000..f5044fc7 --- /dev/null +++ b/examples/resources/sdwan_service_object_tracker_group_profile_parcel/resource.tf @@ -0,0 +1,12 @@ +resource "sdwan_service_object_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + object_tracker_id = 10 + tracker_elements = [ + { + object_tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + reachable = "or" +} diff --git a/examples/resources/sdwan_service_object_tracker_profile_parcel/import.sh b/examples/resources/sdwan_service_object_tracker_profile_parcel/import.sh new file mode 100644 index 00000000..edc9b400 --- /dev/null +++ b/examples/resources/sdwan_service_object_tracker_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_service_object_tracker_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_service_object_tracker_profile_parcel/resource.tf b/examples/resources/sdwan_service_object_tracker_profile_parcel/resource.tf new file mode 100644 index 00000000..1ef3ce3e --- /dev/null +++ b/examples/resources/sdwan_service_object_tracker_profile_parcel/resource.tf @@ -0,0 +1,8 @@ +resource "sdwan_service_object_tracker_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + object_tracker_id = 10 + object_tracker_type = "Interface" + interface = "GigabitEthernet1" +} diff --git a/examples/resources/sdwan_service_tracker_group_profile_parcel/import.sh b/examples/resources/sdwan_service_tracker_group_profile_parcel/import.sh new file mode 100644 index 00000000..d3820f18 --- /dev/null +++ b/examples/resources/sdwan_service_tracker_group_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_service_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_service_tracker_group_profile_parcel/resource.tf b/examples/resources/sdwan_service_tracker_group_profile_parcel/resource.tf new file mode 100644 index 00000000..eccfc472 --- /dev/null +++ b/examples/resources/sdwan_service_tracker_group_profile_parcel/resource.tf @@ -0,0 +1,11 @@ +resource "sdwan_service_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} diff --git a/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/import.sh b/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/import.sh new file mode 100644 index 00000000..af0e6c38 --- /dev/null +++ b/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_transport_ipv6_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/resource.tf b/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/resource.tf new file mode 100644 index 00000000..45e9f71f --- /dev/null +++ b/examples/resources/sdwan_transport_ipv6_tracker_group_profile_parcel/resource.tf @@ -0,0 +1,12 @@ +resource "sdwan_transport_ipv6_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_name = "TRACKER_GROUP_1" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} diff --git a/examples/resources/sdwan_transport_tracker_group_profile_parcel/import.sh b/examples/resources/sdwan_transport_tracker_group_profile_parcel/import.sh new file mode 100644 index 00000000..8fab5785 --- /dev/null +++ b/examples/resources/sdwan_transport_tracker_group_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_transport_tracker_group_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_transport_tracker_group_profile_parcel/resource.tf b/examples/resources/sdwan_transport_tracker_group_profile_parcel/resource.tf new file mode 100644 index 00000000..e62a9fc7 --- /dev/null +++ b/examples/resources/sdwan_transport_tracker_group_profile_parcel/resource.tf @@ -0,0 +1,11 @@ +resource "sdwan_transport_tracker_group_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_elements = [ + { + tracker_id = "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + ] + tracker_boolean = "or" +} diff --git a/examples/resources/sdwan_transport_tracker_profile_parcel/import.sh b/examples/resources/sdwan_transport_tracker_profile_parcel/import.sh new file mode 100644 index 00000000..bdac8a05 --- /dev/null +++ b/examples/resources/sdwan_transport_tracker_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_transport_tracker_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_transport_tracker_profile_parcel/resource.tf b/examples/resources/sdwan_transport_tracker_profile_parcel/resource.tf new file mode 100644 index 00000000..ccd04e4c --- /dev/null +++ b/examples/resources/sdwan_transport_tracker_profile_parcel/resource.tf @@ -0,0 +1,14 @@ +resource "sdwan_transport_tracker_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} diff --git a/gen/definitions/profile_parcels/service_object_tracker.yaml b/gen/definitions/profile_parcels/service_object_tracker.yaml new file mode 100644 index 00000000..705908f9 --- /dev/null +++ b/gen/definitions/profile_parcels/service_object_tracker.yaml @@ -0,0 +1,39 @@ +--- +name: Service Object Tracker +rest_endpoint: /v1/feature-profile/sdwan/service/%v/objecttracker +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_service_feature_profile.test.id + - model_name: objectId + tf_name: object_tracker_id + mandatory: true + example: 10 + test_value: '10' + - model_name: objectTrackerType + mandatory: true + example: Interface + - model_name: interface + example: GigabitEthernet1 + minimum_test_value: '"GigabitEthernet1"' + - model_name: routeIp + example: 1.2.3.4 + exclude_test: true + - model_name: routeMask + example: 0.0.0.0 + exclude_test: true + - model_name: vpn + example: 1 + exclude_test: true + +test_prerequisites: | + resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } diff --git a/gen/definitions/profile_parcels/service_object_tracker_group.yaml b/gen/definitions/profile_parcels/service_object_tracker_group.yaml new file mode 100644 index 00000000..70a5f04a --- /dev/null +++ b/gen/definitions/profile_parcels/service_object_tracker_group.yaml @@ -0,0 +1,56 @@ +name: Service Object Tracker Group +rest_endpoint: /v1/feature-profile/sdwan/service/%v/objecttrackergroup +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +skip_minimum_test: true +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_service_feature_profile.test.id + - model_name: objectId + tf_name: object_tracker_id + mandatory: true + example: 10 + test_value: '10' + - model_name: trackerRefs + tf_name: tracker_elements + attributes: + - model_name: refId + tf_name: object_tracker_id + data_path: [trackerRef] + id: true + mandatory: true + example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec + test_value: sdwan_service_object_tracker_profile_parcel.test-1.id + secondary_test_value: sdwan_service_object_tracker_profile_parcel.test-2.id + - model_name: criteria + tf_name: reachable + example: or + +test_prerequisites: | + resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } + + resource "sdwan_service_object_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 11 + tracker_type = "Interface" + interface = "GigabitEthernet1" + } + + resource "sdwan_service_object_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 12 + tracker_type = "Interface" + interface = "GigabitEthernet1" + } \ No newline at end of file diff --git a/gen/definitions/profile_parcels/service_tracker_group.yaml b/gen/definitions/profile_parcels/service_tracker_group.yaml new file mode 100644 index 00000000..4fd3d9ef --- /dev/null +++ b/gen/definitions/profile_parcels/service_tracker_group.yaml @@ -0,0 +1,68 @@ +--- +name: Service Tracker Group +rest_endpoint: /v1/feature-profile/sdwan/service/%v/trackergroup +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +skip_minimum_test: true +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_service_feature_profile.test.id + - model_name: trackerRefs + tf_name: tracker_elements + attributes: + - model_name: refId + tf_name: tracker_id + data_path: [trackerRef] + id: true + mandatory: true + example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec + test_value: sdwan_service_tracker_profile_parcel.test-1.id + secondary_test_value: sdwan_service_tracker_profile_parcel.test-2.id + - model_name: combineBoolean + tf_name: tracker_boolean + example: or + +test_prerequisites: | + resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } + + resource "sdwan_service_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" + } + + resource "sdwan_service_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" + } \ No newline at end of file diff --git a/gen/definitions/profile_parcels/transport_ipv6_tracker_group.yaml b/gen/definitions/profile_parcels/transport_ipv6_tracker_group.yaml new file mode 100644 index 00000000..06d8d8eb --- /dev/null +++ b/gen/definitions/profile_parcels/transport_ipv6_tracker_group.yaml @@ -0,0 +1,68 @@ +--- +name: Transport IPv6 Tracker Group +rest_endpoint: /v1/feature-profile/sdwan/transport/%v/ipv6-trackergroup +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +skip_minimum_test: true +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_transport_feature_profile.test.id + - model_name: trackerGroupName + tf_name: tracker_name + mandatory: true + example: TRACKER_GROUP_1 + - model_name: trackerRefs + tf_name: tracker_elements + attributes: + - model_name: refId + tf_name: tracker_id + data_path: [trackerRef] + id: true + mandatory: true + example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec + test_value: sdwan_transport_ipv6_tracker_profile_parcel.test-1.id + secondary_test_value: sdwan_transport_ipv6_tracker_profile_parcel.test-2.id + - model_name: combineBoolean + tf_name: tracker_boolean + example: or + +test_prerequisites: | + resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } + + resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" + } + + resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" + } \ No newline at end of file diff --git a/gen/definitions/profile_parcels/transport_tracker.yaml b/gen/definitions/profile_parcels/transport_tracker.yaml new file mode 100644 index 00000000..83287594 --- /dev/null +++ b/gen/definitions/profile_parcels/transport_tracker.yaml @@ -0,0 +1,38 @@ +--- +name: Transport Tracker +rest_endpoint: /v1/feature-profile/sdwan/transport/%v/tracker +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_transport_feature_profile.test.id + - model_name: trackerName + example: TRACKER_1 + minimum_test_value: '"TRACKER_1"' + - model_name: endpointApiUrl + example: google.com + - model_name: endpointDnsName + example: google.com + - model_name: endpointIp + example: 1.2.3.4 + - model_name: interval + example: 30 + - model_name: multiplier + example: 3 + - model_name: threshold + example: 300 + - model_name: endpointTrackerType + example: interface + - model_name: trackerType + example: endpoint + +test_prerequisites: | + resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } \ No newline at end of file diff --git a/gen/definitions/profile_parcels/transport_tracker_group.yaml b/gen/definitions/profile_parcels/transport_tracker_group.yaml new file mode 100644 index 00000000..a61478a5 --- /dev/null +++ b/gen/definitions/profile_parcels/transport_tracker_group.yaml @@ -0,0 +1,64 @@ +--- +name: Transport Tracker Group +rest_endpoint: /v1/feature-profile/sdwan/transport/%v/trackergroup +minimum_version: 20.12.0 +test_tags: [SDWAN_2012] +skip_minimum_test: true +attributes: + - tf_name: feature_profile_id + reference: true + type: String + mandatory: true + description: Feature Profile ID + example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac + test_value: sdwan_transport_feature_profile.test.id + - model_name: trackerRefs + tf_name: tracker_elements + attributes: + - model_name: refId + tf_name: tracker_id + data_path: [trackerRef] + id: true + mandatory: true + example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec + test_value: sdwan_transport_tracker_profile_parcel.test-1.id + secondary_test_value: sdwan_transport_tracker_profile_parcel.test-2.id + - model_name: combineBoolean + tf_name: tracker_boolean + example: or + +test_prerequisites: | + resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } + + resource "sdwan_transport_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" + } + + resource "sdwan_transport_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" + } \ No newline at end of file diff --git a/gen/generator.go b/gen/generator.go index 5c6335ce..9a84df1f 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -203,6 +203,7 @@ type YamlConfig struct { SkipTemplates []string `yaml:"skip_templates"` Attributes []YamlConfigAttribute `yaml:"attributes"` TestTags []string `yaml:"test_tags"` + SkipMinimumTest bool `yaml:"skip_minimum_test"` TestPrerequisites string `yaml:"test_prerequisites"` RemoveId bool `yaml:"remove_id"` TypeValue string `yaml:"type_value"` @@ -255,6 +256,7 @@ type YamlConfigAttribute struct { DefaultValueEmptyString bool `yaml:"default_value_empty_string"` Value string `yaml:"value"` TestValue string `yaml:"test_value"` + SecondaryTestValue string `yaml:"secondary_test_value"` MinimumTestValue string `yaml:"minimum_test_value"` AlwaysInclude bool `yaml:"always_include"` AlwaysIncludeParent bool `yaml:"always_include_parent"` diff --git a/gen/models/profile_parcels/service_object_tracker.json b/gen/models/profile_parcels/service_object_tracker.json new file mode 100644 index 00000000..bd040c5f --- /dev/null +++ b/gen/models/profile_parcels/service_object_tracker.json @@ -0,0 +1,419 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/common/objecttracker/common/request_schema.json", + "title": "common object tracker Feature Schema", + "description": "object tracker profile feature schema for common request", + "type": "object", + "properties": { + "name": { + "description": "Set the tracker name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "objectId": { + "description": "Object tracker ID", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "integer", + "minimum": 1, + "maximum": 1000 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "objectTrackerType": { + "description": "objectTrackerType:Interface SIG Route", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": ["Interface", "SIG", "Route"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "interface": { + "description": "interface name", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "pattern": "(ATM|ATM-ACR|AppGigabitEthernet|AppNav-Compress|AppNav-UnCompress|Async|BD-VIF|BDI|CEM|CEM-ACR|Cellular|Dialer|Embedded-Service-Engine|Ethernet|Ethernet-Internal|FastEthernet|FiftyGigabitEthernet|FiveGigabitEthernet|FortyGigabitEthernet|FourHundredGigE|GMPLS|GigabitEthernet|Group-Async|HundredGigE|L2LISP|LISP|Loopback|MFR|Multilink|Port-channel|SM|Serial|Service-Engine|TenGigabitEthernet|Tunnel|TwentyFiveGigE|TwentyFiveGigabitEthernet|TwoGigabitEthernet|TwoHundredGigE|Vif|Virtual-PPP|Virtual-Template|VirtualPortGroup|Vlan|Wlan-GigabitEthernet|nat64|nat66|ntp|nve|ospfv3|overlay|pseudowire|ucse|vasileft|vasiright|vmi)([0-9]*(. ?[1-9][0-9]*)*|[0-9/]+|[0-9]+/[0-9]+/[0-9]+:[0-9]+|[0-9]+/[0-9]+/[0-9]+|[0-9]+/[0-9]+|[0-9]+)", + "minLength": 3, + "maxLength": 32 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "routeIp": { + "description": "IP address", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "routeMask": { + "description": "IP mask", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": [ + "255.255.255.255", + "255.255.255.254", + "255.255.255.252", + "255.255.255.248", + "255.255.255.240", + "255.255.255.224", + "255.255.255.192", + "255.255.255.128", + "255.255.255.0", + "255.255.254.0", + "255.255.252.0", + "255.255.248.0", + "255.255.240.0", + "255.255.224.0", + "255.255.192.0", + "255.255.128.0", + "255.255.0.0", + "255.254.0.0", + "255.252.0.0", + "255.240.0.0", + "255.224.0.0", + "255.192.0.0", + "255.128.0.0", + "255.0.0.0", + "254.0.0.0", + "252.0.0.0", + "248.0.0.0", + "240.0.0.0", + "224.0.0.0", + "192.0.0.0", + "128.0.0.0", + "0.0.0.0" + ] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["default"] + }, + "value": { + "enum": ["0.0.0.0"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "vpn": { + "description": "VPN", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "integer", + "minimum": 0, + "maximum": 65530 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["default"] + } + }, + "required": ["optionType"], + "additionalProperties": false + } + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "objectTrackerType": { + "properties": { + "value": { + "const": "Interface" + } + } + } + } + }, + "then": { + "required": ["objectId", "interface"] + } + }, + { + "if": { + "properties": { + "objectTrackerType": { + "properties": { + "value": { + "const": "Route" + } + } + } + } + }, + "then": { + "required": ["objectId", "routeIp", "routeMask", "vpn"] + } + }, + { + "if": { + "properties": { + "objectTrackerType": { + "properties": { + "value": { + "const": "SIG" + } + } + } + } + }, + "then": { + "required": ["objectId"] + } + } + ], + "additionalProperties": false + }, + "documentation": { + "description": "This is the documentation for common request schema for common LAN VPN profile feature", + "examples": [ + { + "name": "zjtest-object-tracker-interface", + "description": "zjtest-object-tracker-interface", + "data": { + "objectId": { + "optionType": "global", + "value": 10 + }, + "interface": { + "optionType": "global", + "value": "GigabitEthernet1" + }, + "objectTrackerType": { + "optionType": "global", + "value": "Interface" + } + } + } + ] + }, + "metadata": { + "minVManageVersion": "20.15.1" + } + }, + "required": ["data"], + "not": { + "required": ["documentation", "metadata"] + }, + "additionalProperties": false + } +} diff --git a/gen/models/profile_parcels/service_object_tracker_group.json b/gen/models/profile_parcels/service_object_tracker_group.json new file mode 100644 index 00000000..ba8a893f --- /dev/null +++ b/gen/models/profile_parcels/service_object_tracker_group.json @@ -0,0 +1,221 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/common/objecttrackergroup/common/request_schema.json", + "title": "common object tracker group Schema", + "description": "common Object TrackerGroup profile feature schema for common request", + "type": "object", + "properties": { + "name": { + "description": "Set the feature name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "description": "Set the parcel description", + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "objectId": { + "description": "Object ID", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "integer", + "minimum": 1, + "maximum": 1000 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "trackerRefs": { + "description": "Group Tracks ID Refs", + "type": "array", + "items": { + "type": "object", + "properties": { + "trackerRef": { + "properties": { + "refId": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "pattern": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["refId"], + "additionalProperties": false + } + }, + "required": ["trackerRef"], + "additionalProperties": false + }, + "minItems": 2, + "maxItems": 2, + "uniqueItems": true + }, + "criteria": { + "description": "tracker ref list criteria boolean and or", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["variable"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 128 + }, + "default": { + "minLength": 1, + "type": "string", + "maxLength": 2048 + }, + "description": { + "minLength": 1, + "type": "string", + "maxLength": 128 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["and", "or"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": ["default"] + }, + "value": { + "type": "string", + "enum": ["or"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + } + }, + "required": ["objectId", "trackerRefs", "criteria"], + "additionalProperties": false + }, + "metadata": { + "parcelRefDefinition": [ + { + "refIdPath": "data.trackerRefs[*].trackerRef", + "parcelType": ["objecttracker"] + } + ], + "minVManageVersion": "20.15.1" + }, + "documentation": { + "description": "This is the documentation for common request schema for common LAN VPN profile feature", + "examples": [ + { + "data": { + "objectId": { + "optionType": "global", + "value": 12 + }, + "trackerRefs": [ + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + } + }, + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec12" + } + } + } + ], + "combineBoolean": { + "optionType": "global", + "value": "and" + } + }, + "description": "common_object_track_group_cedge_parcel_1", + "name": "common_object_track_group_cedge_parcel_1" + } + ] + } + }, + "required": ["name", "data"], + "not": { + "required": ["metadata", "documentation"] + }, + "additionalProperties": false + } +} diff --git a/gen/models/profile_parcels/service_tracker_group.json b/gen/models/profile_parcels/service_tracker_group.json new file mode 100644 index 00000000..410e4327 --- /dev/null +++ b/gen/models/profile_parcels/service_tracker_group.json @@ -0,0 +1,199 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/common/trackergroup/common/request_schema.json", + "title": "common tracker group Schema", + "description": "TrackerGroup profile parcel schema for common request", + "type": "object", + "properties": { + "name": { + "description": "Set the parcel name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "description": "Set the parcel description", + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "trackerRefs": { + "description": "tracker parcel ref list", + "type": "array", + "items": { + "type": "object", + "properties": { + "trackerRef": { + "properties": { + "refId": { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "pattern": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + }, + "required": [ + "refId" + ], + "additionalProperties": false + } + }, + "required": [ + "trackerRef" + ], + "additionalProperties": false + }, + "minItems": 2, + "maxItems": 2, + "uniqueItems": true + }, + "combineBoolean": { + "description": "tracker ref list combine boolean and or", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "variable" + ] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "enum": [ + "and", + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "default" + ] + }, + "value": { + "type": "string", + "enum": [ + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "required": [ + "trackerRefs", + "combineBoolean" + ], + "additionalProperties": false + }, + "metadata": { + "parcelRefDefinition": [ + { + "refIdPath": "data.trackerRefs[*].trackerRef", + "parcelType": [ + "tracker" + ] + } + ] + }, + "documentation": { + "description": "This is the documentation for common request schema for common LAN/WAN VPN profile parcel", + "examples": [ + { + "data": { + "trackerRefs": [ + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + } + }, + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec12" + } + } + } + ], + "combineBoolean": { + "optionType": "global", + "value": "and" + } + }, + "description": "common_track_group_cedge_parcel_1", + "name": "common_track_group_cedge_parcel_1" + } + ] + } + }, + "required": [ + "name", + "data" + ], + "not": { + "required": [ + "metadata", + "documentation" + ] + }, + "additionalProperties": false + } +} \ No newline at end of file diff --git a/gen/models/profile_parcels/transport_ipv6_tracker_group.json b/gen/models/profile_parcels/transport_ipv6_tracker_group.json new file mode 100644 index 00000000..4502cb64 --- /dev/null +++ b/gen/models/profile_parcels/transport_ipv6_tracker_group.json @@ -0,0 +1,247 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/transport/ipv6-trackergroup/common/request_schema.json", + "title": "transport ipv6 tracker group Schema", + "description": "IPv6 TrackerGroup profile parcel schema for common request", + "type": "object", + "properties": { + "name": { + "description": "Set the feature name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "description": "Set the feature description", + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "trackerGroupName": { + "description": "Tracker Name", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "variable" + ] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "minLength": 1, + "maxLength": 128, + "type": "string" + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + ] + }, + "trackerRefs": { + "description": "trackers ref list", + "type": "array", + "items": { + "type": "object", + "properties": { + "trackerRef": { + "properties": { + "refId": { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "pattern": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + }, + "required": [ + "refId" + ], + "additionalProperties": false + } + }, + "required": [ + "trackerRef" + ], + "additionalProperties": false + }, + "minItems": 2, + "maxItems": 2, + "uniqueItems": true + }, + "combineBoolean": { + "description": "tracker ref list combine boolean and or", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "variable" + ] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "enum": [ + "and", + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "default" + ] + }, + "value": { + "type": "string", + "enum": [ + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "required": [ + "trackerGroupName", + "trackerRefs", + "combineBoolean" + ], + "additionalProperties": false + }, + "metadata": { + "parcelRefDefinition": [ + { + "refIdPath": "data.trackerRefs[*].trackerRef", + "parcelType": [ + "ipv6-tracker" + ] + } + ] + }, + "documentation": { + "description": "This is the documentation for common request schema for WAN VPN ipv6-trackergroup profile parcel", + "examples": [ + { + "data": { + "trackerRefs": [ + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + } + }, + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec12" + } + } + } + ], + "combineBoolean": { + "optionType": "global", + "value": "and" + } + }, + "description": "common_track_group_cedge_parcel_1", + "name": "common_track_group_cedge_parcel_1" + } + ] + } + }, + "required": [ + "name", + "data" + ], + "not": { + "required": [ + "metadata", + "documentation" + ] + }, + "additionalProperties": false + } +} \ No newline at end of file diff --git a/gen/models/profile_parcels/transport_tracker.json b/gen/models/profile_parcels/transport_tracker.json new file mode 100644 index 00000000..fbbe7f2f --- /dev/null +++ b/gen/models/profile_parcels/transport_tracker.json @@ -0,0 +1,608 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/transport/tracker/common/request_schema.json", + "title": "WAN tracker Schema", + "description": "Tracker profile parcel schema for common request", + "type": "object", + "properties": { + "name": { + "description": "Set the parcel name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "description": "Set the parcel description", + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "trackerName": { + "description": "Tracker Name", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "variable" + ] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "minLength": 1, + "maxLength": 128, + "pattern": "^[^! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "description": "Set the parcel description", + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "trackerRefs": { + "description": "tracker parcel ref list", + "type": "array", + "items": { + "type": "object", + "properties": { + "trackerRef": { + "properties": { + "refId": { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "pattern": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + }, + "required": [ + "refId" + ], + "additionalProperties": false + } + }, + "required": [ + "trackerRef" + ], + "additionalProperties": false + }, + "minItems": 2, + "maxItems": 2, + "uniqueItems": true + }, + "combineBoolean": { + "description": "tracker ref list combine boolean and or", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "variable" + ] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[.\/\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "global" + ] + }, + "value": { + "type": "string", + "enum": [ + "and", + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + }, + { + "properties": { + "optionType": { + "type": "string", + "enum": [ + "default" + ] + }, + "value": { + "type": "string", + "enum": [ + "or" + ] + } + }, + "required": [ + "optionType", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "required": [ + "trackerRefs", + "combineBoolean" + ], + "additionalProperties": false + }, + "metadata": { + "parcelRefDefinition": [ + { + "refIdPath": "data.trackerRefs[*].trackerRef", + "parcelType": [ + "tracker" + ] + } + ] + }, + "documentation": { + "description": "This is the documentation for common request schema for common LAN/WAN VPN profile parcel", + "examples": [ + { + "data": { + "trackerRefs": [ + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec" + } + } + }, + { + "trackerRef": { + "refId": { + "optionType": "global", + "value": "615d948f-34ee-4a2e-810e-a9bd8d3d48ec12" + } + } + } + ], + "combineBoolean": { + "optionType": "global", + "value": "and" + } + }, + "description": "common_track_group_cedge_parcel_1", + "name": "common_track_group_cedge_parcel_1" + } + ] + } + }, + "required": [ + "name", + "data" + ], + "not": { + "required": [ + "metadata", + "documentation" + ] + }, + "additionalProperties": false + } +} \ No newline at end of file diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 91b0bc6f..2a256d76 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -25,6 +25,7 @@ no_data_source: bool(required=False) # Set to true if no data source should be c no_resource: bool(required=False) # Set to true if no resource should be created get_before_delete: bool(required=False) # This does a GET "all" before doing a DELETE, which is a workaround for an API issue with some endpoints where the reference count is not updated otherwise delete_mutex: bool(required=False) # Set to true if DELETE operation is mutually exclusive with other DELETE operations +skip_minimum_test: bool(required=False) # Set to true to prevent "minimum" resource acceptance testing --- attribute: model_name: str(required=False) # Name of the attribute in the model (payload) @@ -68,6 +69,7 @@ attribute: default_value_empty_string: bool(required=False) # Set to true if default value should be an empty string value: any(str(), int(), bool(), required=False) # Hardcoded value for the attribute test_value: str(required=False) # Value used for acceptance test + secondary_test_value: str(required=False) # Value used for acceptance test minimum_test_value: any(str(), int(), bool(), num(), required=False) # Value used for "minimum" resource acceptance test always_include: bool(required=False) # Include attribute always in payload always_include_parent: bool(required=False) # Include attributes parent always in payload diff --git a/gen/templates/profile_parcels/data_source_test.go b/gen/templates/profile_parcels/data_source_test.go index 5e231a73..179efce6 100644 --- a/gen/templates/profile_parcels/data_source_test.go +++ b/gen/templates/profile_parcels/data_source_test.go @@ -36,28 +36,28 @@ func TestAccDataSourceSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) { var checks []resource.TestCheckFunc {{- $name := .Name }} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $list := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $clist := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $cclist := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not (isListSet .))}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue) (not (isListSet .))}} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_{{snakeCase $name}}_profile_parcel.test", "{{$list}}.0.{{$clist}}.0.{{$cclist}}.0.{{.TfName}}", "{{.Example}}")) @@ -161,9 +161,17 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} @@ -175,9 +183,17 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} @@ -190,9 +206,17 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} diff --git a/gen/templates/profile_parcels/resource_test.go b/gen/templates/profile_parcels/resource_test.go index f67f8526..8a271475 100644 --- a/gen/templates/profile_parcels/resource_test.go +++ b/gen/templates/profile_parcels/resource_test.go @@ -36,28 +36,28 @@ func TestAccSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) { var checks []resource.TestCheckFunc {{- $name := .Name }} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $list := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $clist := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}} {{- if isNestedListSet .}} {{- $cclist := .TfName }} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { {{- end}} {{- range .Attributes}} - {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not (isListSet .))}} + {{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue) (not (isListSet .))}} {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { checks = append(checks, resource.TestCheckResourceAttr("sdwan_{{snakeCase $name}}_profile_parcel.test", "{{$list}}.0.{{$clist}}.0.{{$cclist}}.0.{{.TfName}}", "{{.Example}}")) @@ -113,9 +113,9 @@ func TestAccSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) { PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - { + {{if not .SkipMinimumTest}}{ Config: {{if .TestPrerequisites}}testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig+{{end}}testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum(), - }, + },{{end}} { Config: {{if .TestPrerequisites}}testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig+{{end}}testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all(), Check: resource.ComposeTestCheckFunc(checks...), @@ -134,7 +134,7 @@ const testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig = ` // End of section. //template:end testPrerequisites // Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum -func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string { +{{if not .SkipMinimumTest}}func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string { config := `resource "sdwan_{{snakeCase $name}}_profile_parcel" "test" {` + "\n" config += ` name = "TF_TEST_MIN"` + "\n" config += ` description = "Terraform integration test"` + "\n" @@ -151,7 +151,7 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string { {{- end}} config += `}` + "\n" return config -} +}{{end}} // End of section. //template:end testAccConfigMinimum // Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll @@ -185,9 +185,17 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} @@ -199,9 +207,17 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} @@ -214,9 +230,17 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string { {{- if len .TestTags}} if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} { config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} } {{- else}} config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n" + {{- if .SecondaryTestValue}} + config += ` }, {` + "\n" + config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n" + {{- end}} {{- end}} {{- end}} {{- end}} diff --git a/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel.go b/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel.go new file mode 100644 index 00000000..f9829d8b --- /dev/null +++ b/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel.go @@ -0,0 +1,150 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &ServiceObjectTrackerGroupProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &ServiceObjectTrackerGroupProfileParcelDataSource{} +) + +func NewServiceObjectTrackerGroupProfileParcelDataSource() datasource.DataSource { + return &ServiceObjectTrackerGroupProfileParcelDataSource{} +} + +type ServiceObjectTrackerGroupProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *ServiceObjectTrackerGroupProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_object_tracker_group_profile_parcel" +} + +func (d *ServiceObjectTrackerGroupProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Service Object Tracker Group profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "object_tracker_id": schema.Int64Attribute{ + MarkdownDescription: "Object ID", + Computed: true, + }, + "object_tracker_id_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: "Group Tracks ID Refs", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "object_tracker_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "reachable": schema.StringAttribute{ + MarkdownDescription: "tracker ref list criteria boolean and or", + Computed: true, + }, + "reachable_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *ServiceObjectTrackerGroupProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *ServiceObjectTrackerGroupProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config ServiceObjectTrackerGroup + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel_test.go b/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..b38ccabd --- /dev/null +++ b/internal/provider/data_source_sdwan_service_object_tracker_group_profile_parcel_test.go @@ -0,0 +1,103 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanServiceObjectTrackerGroupProfileParcel(t *testing.T) { + 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_service_object_tracker_group_profile_parcel.test", "reachable", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanServiceObjectTrackerGroupPrerequisitesProfileParcelConfig + testAccDataSourceSdwanServiceObjectTrackerGroupProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanServiceObjectTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_service_object_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 11 + tracker_type = "Interface" + interface = "GigabitEthernet1" +} + +resource "sdwan_service_object_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 12 + tracker_type = "Interface" + interface = "GigabitEthernet1" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanServiceObjectTrackerGroupProfileParcelConfig() string { + config := `resource "sdwan_service_object_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` object_tracker_id = 10` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` object_tracker_id = sdwan_service_object_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` object_tracker_id = sdwan_service_object_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` reachable = "or"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_service_object_tracker_group_profile_parcel" "test" { + id = sdwan_service_object_tracker_group_profile_parcel.test.id + feature_profile_id = sdwan_service_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel.go b/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel.go new file mode 100644 index 00000000..e5f7966b --- /dev/null +++ b/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel.go @@ -0,0 +1,166 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &ServiceObjectTrackerProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &ServiceObjectTrackerProfileParcelDataSource{} +) + +func NewServiceObjectTrackerProfileParcelDataSource() datasource.DataSource { + return &ServiceObjectTrackerProfileParcelDataSource{} +} + +type ServiceObjectTrackerProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *ServiceObjectTrackerProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_object_tracker_profile_parcel" +} + +func (d *ServiceObjectTrackerProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Service Object Tracker profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "object_tracker_id": schema.Int64Attribute{ + MarkdownDescription: "Object tracker ID", + Computed: true, + }, + "object_tracker_id_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "object_tracker_type": schema.StringAttribute{ + MarkdownDescription: "objectTrackerType:Interface SIG Route", + Computed: true, + }, + "interface": schema.StringAttribute{ + MarkdownDescription: "interface name", + Computed: true, + }, + "interface_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "route_ip": schema.StringAttribute{ + MarkdownDescription: "IP address", + Computed: true, + }, + "route_ip_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "route_mask": schema.StringAttribute{ + MarkdownDescription: "IP mask", + Computed: true, + }, + "route_mask_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "vpn": schema.Int64Attribute{ + MarkdownDescription: "VPN", + Computed: true, + }, + "vpn_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *ServiceObjectTrackerProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *ServiceObjectTrackerProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config ServiceObjectTracker + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel_test.go b/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel_test.go new file mode 100644 index 00000000..2c43576f --- /dev/null +++ b/internal/provider/data_source_sdwan_service_object_tracker_profile_parcel_test.go @@ -0,0 +1,83 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanServiceObjectTrackerProfileParcel(t *testing.T) { + 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_service_object_tracker_profile_parcel.test", "object_tracker_type", "Interface")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_object_tracker_profile_parcel.test", "interface", "GigabitEthernet1")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanServiceObjectTrackerPrerequisitesProfileParcelConfig + testAccDataSourceSdwanServiceObjectTrackerProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanServiceObjectTrackerPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanServiceObjectTrackerProfileParcelConfig() string { + config := `resource "sdwan_service_object_tracker_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` object_tracker_id = 10` + "\n" + config += ` object_tracker_type = "Interface"` + "\n" + config += ` interface = "GigabitEthernet1"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_service_object_tracker_profile_parcel" "test" { + id = sdwan_service_object_tracker_profile_parcel.test.id + feature_profile_id = sdwan_service_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel.go b/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel.go new file mode 100644 index 00000000..1b59baff --- /dev/null +++ b/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel.go @@ -0,0 +1,142 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &ServiceTrackerGroupProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &ServiceTrackerGroupProfileParcelDataSource{} +) + +func NewServiceTrackerGroupProfileParcelDataSource() datasource.DataSource { + return &ServiceTrackerGroupProfileParcelDataSource{} +} + +type ServiceTrackerGroupProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *ServiceTrackerGroupProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_tracker_group_profile_parcel" +} + +func (d *ServiceTrackerGroupProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Service Tracker Group profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: "tracker parcel ref list", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: "tracker ref list combine boolean and or", + Computed: true, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *ServiceTrackerGroupProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *ServiceTrackerGroupProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config ServiceTrackerGroup + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel_test.go b/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..1b970162 --- /dev/null +++ b/internal/provider/data_source_sdwan_service_tracker_group_profile_parcel_test.go @@ -0,0 +1,118 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanServiceTrackerGroupProfileParcel(t *testing.T) { + 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_service_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanServiceTrackerGroupPrerequisitesProfileParcelConfig + testAccDataSourceSdwanServiceTrackerGroupProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanServiceTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_service_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" +} + +resource "sdwan_service_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanServiceTrackerGroupProfileParcelConfig() string { + config := `resource "sdwan_service_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_service_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_service_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_service_tracker_group_profile_parcel" "test" { + id = sdwan_service_tracker_group_profile_parcel.test.id + feature_profile_id = sdwan_service_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel.go b/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel.go new file mode 100644 index 00000000..8cc45a1d --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel.go @@ -0,0 +1,150 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &TransportIPv6TrackerGroupProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &TransportIPv6TrackerGroupProfileParcelDataSource{} +) + +func NewTransportIPv6TrackerGroupProfileParcelDataSource() datasource.DataSource { + return &TransportIPv6TrackerGroupProfileParcelDataSource{} +} + +type TransportIPv6TrackerGroupProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *TransportIPv6TrackerGroupProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_ipv6_tracker_group_profile_parcel" +} + +func (d *TransportIPv6TrackerGroupProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Transport IPv6 Tracker Group profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "tracker_name": schema.StringAttribute{ + MarkdownDescription: "Tracker Name", + Computed: true, + }, + "tracker_name_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: "trackers ref list", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: "tracker ref list combine boolean and or", + Computed: true, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *TransportIPv6TrackerGroupProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *TransportIPv6TrackerGroupProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config TransportIPv6TrackerGroup + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go b/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..878d17e8 --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go @@ -0,0 +1,116 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanTransportIPv6TrackerGroupProfileParcel(t *testing.T) { + 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_transport_ipv6_tracker_group_profile_parcel.test", "tracker_name", "TRACKER_GROUP_1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_ipv6_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanTransportIPv6TrackerGroupPrerequisitesProfileParcelConfig + testAccDataSourceSdwanTransportIPv6TrackerGroupProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanTransportIPv6TrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" +} + +resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanTransportIPv6TrackerGroupProfileParcelConfig() string { + config := `resource "sdwan_transport_ipv6_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_transport_feature_profile.test.id` + "\n" + config += ` tracker_name = "TRACKER_GROUP_1"` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_transport_ipv6_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_transport_ipv6_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_transport_ipv6_tracker_group_profile_parcel" "test" { + id = sdwan_transport_ipv6_tracker_group_profile_parcel.test.id + feature_profile_id = sdwan_transport_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel.go b/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel.go new file mode 100644 index 00000000..e91d91f9 --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel.go @@ -0,0 +1,142 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &TransportTrackerGroupProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &TransportTrackerGroupProfileParcelDataSource{} +) + +func NewTransportTrackerGroupProfileParcelDataSource() datasource.DataSource { + return &TransportTrackerGroupProfileParcelDataSource{} +} + +type TransportTrackerGroupProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *TransportTrackerGroupProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_tracker_group_profile_parcel" +} + +func (d *TransportTrackerGroupProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Transport Tracker Group profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: "tracker parcel ref list", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: "tracker ref list combine boolean and or", + Computed: true, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *TransportTrackerGroupProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *TransportTrackerGroupProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config TransportTrackerGroup + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel_test.go b/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..c322e14a --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_tracker_group_profile_parcel_test.go @@ -0,0 +1,114 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanTransportTrackerGroupProfileParcel(t *testing.T) { + 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_transport_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanTransportTrackerGroupPrerequisitesProfileParcelConfig + testAccDataSourceSdwanTransportTrackerGroupProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanTransportTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_transport_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} + +resource "sdwan_transport_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanTransportTrackerGroupProfileParcelConfig() string { + config := `resource "sdwan_transport_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_transport_feature_profile.test.id` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_transport_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_transport_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_transport_tracker_group_profile_parcel" "test" { + id = sdwan_transport_tracker_group_profile_parcel.test.id + feature_profile_id = sdwan_transport_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/data_source_sdwan_transport_tracker_profile_parcel.go b/internal/provider/data_source_sdwan_transport_tracker_profile_parcel.go new file mode 100644 index 00000000..3f28e2e8 --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_tracker_profile_parcel.go @@ -0,0 +1,194 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "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 = &TransportTrackerProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &TransportTrackerProfileParcelDataSource{} +) + +func NewTransportTrackerProfileParcelDataSource() datasource.DataSource { + return &TransportTrackerProfileParcelDataSource{} +} + +type TransportTrackerProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *TransportTrackerProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_tracker_profile_parcel" +} + +func (d *TransportTrackerProfileParcelDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Transport Tracker profile parcel.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Required: true, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Computed: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: "Feature Profile ID", + Required: true, + }, + "tracker_name": schema.StringAttribute{ + MarkdownDescription: "Tracker Name", + Computed: true, + }, + "tracker_name_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "endpoint_api_url": schema.StringAttribute{ + MarkdownDescription: "API url of endpoint", + Computed: true, + }, + "endpoint_api_url_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "endpoint_dns_name": schema.StringAttribute{ + MarkdownDescription: "Endpoint DNS Name", + Computed: true, + }, + "endpoint_dns_name_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "endpoint_ip": schema.StringAttribute{ + MarkdownDescription: "Endpoint IP", + Computed: true, + }, + "endpoint_ip_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "interval": schema.Int64Attribute{ + MarkdownDescription: "Interval", + Computed: true, + }, + "interval_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "multiplier": schema.Int64Attribute{ + MarkdownDescription: "Multiplier", + Computed: true, + }, + "multiplier_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "threshold": schema.Int64Attribute{ + MarkdownDescription: "Threshold", + Computed: true, + }, + "threshold_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "endpoint_tracker_type": schema.StringAttribute{ + MarkdownDescription: "Endpoint Tracker Type", + Computed: true, + }, + "endpoint_tracker_type_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + "tracker_type": schema.StringAttribute{ + MarkdownDescription: "Tracker Type", + Computed: true, + }, + "tracker_type_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Computed: true, + }, + }, + } +} + +func (d *TransportTrackerProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + 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 *TransportTrackerProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config TransportTracker + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_transport_tracker_profile_parcel_test.go b/internal/provider/data_source_sdwan_transport_tracker_profile_parcel_test.go new file mode 100644 index 00000000..d815ea51 --- /dev/null +++ b/internal/provider/data_source_sdwan_transport_tracker_profile_parcel_test.go @@ -0,0 +1,95 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource +func TestAccDataSourceSdwanTransportTrackerProfileParcel(t *testing.T) { + 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_transport_tracker_profile_parcel.test", "tracker_name", "TRACKER_1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "endpoint_api_url", "google.com")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "endpoint_dns_name", "google.com")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "endpoint_ip", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "interval", "30")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "multiplier", "3")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "threshold", "300")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "endpoint_tracker_type", "interface")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_tracker_profile_parcel.test", "tracker_type", "endpoint")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanTransportTrackerPrerequisitesProfileParcelConfig + testAccDataSourceSdwanTransportTrackerProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanTransportTrackerPrerequisitesProfileParcelConfig = ` +resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig +func testAccDataSourceSdwanTransportTrackerProfileParcelConfig() string { + config := `resource "sdwan_transport_tracker_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_transport_feature_profile.test.id` + "\n" + config += ` tracker_name = "TRACKER_1"` + "\n" + config += ` endpoint_api_url = "google.com"` + "\n" + config += ` endpoint_dns_name = "google.com"` + "\n" + config += ` endpoint_ip = "1.2.3.4"` + "\n" + config += ` interval = 30` + "\n" + config += ` multiplier = 3` + "\n" + config += ` threshold = 300` + "\n" + config += ` endpoint_tracker_type = "interface"` + "\n" + config += ` tracker_type = "endpoint"` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_transport_tracker_profile_parcel" "test" { + id = sdwan_transport_tracker_profile_parcel.test.id + feature_profile_id = sdwan_transport_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/model_sdwan_service_object_tracker_group_profile_parcel.go b/internal/provider/model_sdwan_service_object_tracker_group_profile_parcel.go new file mode 100644 index 00000000..ec6501ac --- /dev/null +++ b/internal/provider/model_sdwan_service_object_tracker_group_profile_parcel.go @@ -0,0 +1,246 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type ServiceObjectTrackerGroup struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + ObjectTrackerId types.Int64 `tfsdk:"object_tracker_id"` + ObjectTrackerIdVariable types.String `tfsdk:"object_tracker_id_variable"` + TrackerElements []ServiceObjectTrackerGroupTrackerElements `tfsdk:"tracker_elements"` + Reachable types.String `tfsdk:"reachable"` + ReachableVariable types.String `tfsdk:"reachable_variable"` +} + +type ServiceObjectTrackerGroupTrackerElements struct { + ObjectTrackerId types.String `tfsdk:"object_tracker_id"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data ServiceObjectTrackerGroup) getModel() string { + return "service_object_tracker_group" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data ServiceObjectTrackerGroup) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/service/%v/objecttrackergroup", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data ServiceObjectTrackerGroup) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + if !data.ObjectTrackerIdVariable.IsNull() { + body, _ = sjson.Set(body, path+"objectId.optionType", "variable") + body, _ = sjson.Set(body, path+"objectId.value", data.ObjectTrackerIdVariable.ValueString()) + } else if !data.ObjectTrackerId.IsNull() { + body, _ = sjson.Set(body, path+"objectId.optionType", "global") + body, _ = sjson.Set(body, path+"objectId.value", data.ObjectTrackerId.ValueInt64()) + } + + for _, item := range data.TrackerElements { + itemBody := "" + if !item.ObjectTrackerId.IsNull() { + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.value", item.ObjectTrackerId.ValueString()) + } + body, _ = sjson.SetRaw(body, path+"trackerRefs.-1", itemBody) + } + + if !data.ReachableVariable.IsNull() { + body, _ = sjson.Set(body, path+"criteria.optionType", "variable") + body, _ = sjson.Set(body, path+"criteria.value", data.ReachableVariable.ValueString()) + } else if data.Reachable.IsNull() { + body, _ = sjson.Set(body, path+"criteria.optionType", "default") + body, _ = sjson.Set(body, path+"criteria.value", "or") + } else { + body, _ = sjson.Set(body, path+"criteria.optionType", "global") + body, _ = sjson.Set(body, path+"criteria.value", data.Reachable.ValueString()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *ServiceObjectTrackerGroup) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.ObjectTrackerId = types.Int64Null() + data.ObjectTrackerIdVariable = types.StringNull() + if t := res.Get(path + "objectId.optionType"); t.Exists() { + va := res.Get(path + "objectId.value") + if t.String() == "variable" { + data.ObjectTrackerIdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.ObjectTrackerId = types.Int64Value(va.Int()) + } + } + if value := res.Get(path + "trackerRefs"); value.Exists() { + data.TrackerElements = make([]ServiceObjectTrackerGroupTrackerElements, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := ServiceObjectTrackerGroupTrackerElements{} + item.ObjectTrackerId = types.StringNull() + + if t := v.Get("trackerRef.refId.optionType"); t.Exists() { + va := v.Get("trackerRef.refId.value") + if t.String() == "global" { + item.ObjectTrackerId = types.StringValue(va.String()) + } + } + data.TrackerElements = append(data.TrackerElements, item) + return true + }) + } + data.Reachable = types.StringNull() + data.ReachableVariable = types.StringNull() + if t := res.Get(path + "criteria.optionType"); t.Exists() { + va := res.Get(path + "criteria.value") + if t.String() == "variable" { + data.ReachableVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Reachable = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *ServiceObjectTrackerGroup) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.ObjectTrackerId = types.Int64Null() + data.ObjectTrackerIdVariable = types.StringNull() + if t := res.Get(path + "objectId.optionType"); t.Exists() { + va := res.Get(path + "objectId.value") + if t.String() == "variable" { + data.ObjectTrackerIdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.ObjectTrackerId = types.Int64Value(va.Int()) + } + } + for i := range data.TrackerElements { + keys := [...]string{"trackerRef.refId"} + keyValues := [...]string{data.TrackerElements[i].ObjectTrackerId.ValueString()} + keyValuesVariables := [...]string{""} + + var r gjson.Result + res.Get(path + "trackerRefs").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + tt := v.Get(keys[ik] + ".optionType").String() + vv := v.Get(keys[ik] + ".value").String() + if (tt == "variable" && vv == keyValuesVariables[ik]) || (tt == "global" && vv == keyValues[ik]) { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + data.TrackerElements[i].ObjectTrackerId = types.StringNull() + + if t := r.Get("trackerRef.refId.optionType"); t.Exists() { + va := r.Get("trackerRef.refId.value") + if t.String() == "global" { + data.TrackerElements[i].ObjectTrackerId = types.StringValue(va.String()) + } + } + } + data.Reachable = types.StringNull() + data.ReachableVariable = types.StringNull() + if t := res.Get(path + "criteria.optionType"); t.Exists() { + va := res.Get(path + "criteria.value") + if t.String() == "variable" { + data.ReachableVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Reachable = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *ServiceObjectTrackerGroup) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if !data.ObjectTrackerId.IsNull() { + return false + } + if !data.ObjectTrackerIdVariable.IsNull() { + return false + } + if len(data.TrackerElements) > 0 { + return false + } + if !data.Reachable.IsNull() { + return false + } + if !data.ReachableVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/model_sdwan_service_object_tracker_profile_parcel.go b/internal/provider/model_sdwan_service_object_tracker_profile_parcel.go new file mode 100644 index 00000000..e14bbaad --- /dev/null +++ b/internal/provider/model_sdwan_service_object_tracker_profile_parcel.go @@ -0,0 +1,313 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type ServiceObjectTracker struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + ObjectTrackerId types.Int64 `tfsdk:"object_tracker_id"` + ObjectTrackerIdVariable types.String `tfsdk:"object_tracker_id_variable"` + ObjectTrackerType types.String `tfsdk:"object_tracker_type"` + Interface types.String `tfsdk:"interface"` + InterfaceVariable types.String `tfsdk:"interface_variable"` + RouteIp types.String `tfsdk:"route_ip"` + RouteIpVariable types.String `tfsdk:"route_ip_variable"` + RouteMask types.String `tfsdk:"route_mask"` + RouteMaskVariable types.String `tfsdk:"route_mask_variable"` + Vpn types.Int64 `tfsdk:"vpn"` + VpnVariable types.String `tfsdk:"vpn_variable"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data ServiceObjectTracker) getModel() string { + return "service_object_tracker" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data ServiceObjectTracker) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/service/%v/objecttracker", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data ServiceObjectTracker) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + if !data.ObjectTrackerIdVariable.IsNull() { + body, _ = sjson.Set(body, path+"objectId.optionType", "variable") + body, _ = sjson.Set(body, path+"objectId.value", data.ObjectTrackerIdVariable.ValueString()) + } else if !data.ObjectTrackerId.IsNull() { + body, _ = sjson.Set(body, path+"objectId.optionType", "global") + body, _ = sjson.Set(body, path+"objectId.value", data.ObjectTrackerId.ValueInt64()) + } + if !data.ObjectTrackerType.IsNull() { + body, _ = sjson.Set(body, path+"objectTrackerType.optionType", "global") + body, _ = sjson.Set(body, path+"objectTrackerType.value", data.ObjectTrackerType.ValueString()) + } + + if !data.InterfaceVariable.IsNull() { + body, _ = sjson.Set(body, path+"interface.optionType", "variable") + body, _ = sjson.Set(body, path+"interface.value", data.InterfaceVariable.ValueString()) + } else if !data.Interface.IsNull() { + body, _ = sjson.Set(body, path+"interface.optionType", "global") + body, _ = sjson.Set(body, path+"interface.value", data.Interface.ValueString()) + } + + if !data.RouteIpVariable.IsNull() { + body, _ = sjson.Set(body, path+"routeIp.optionType", "variable") + body, _ = sjson.Set(body, path+"routeIp.value", data.RouteIpVariable.ValueString()) + } else if !data.RouteIp.IsNull() { + body, _ = sjson.Set(body, path+"routeIp.optionType", "global") + body, _ = sjson.Set(body, path+"routeIp.value", data.RouteIp.ValueString()) + } + + if !data.RouteMaskVariable.IsNull() { + body, _ = sjson.Set(body, path+"routeMask.optionType", "variable") + body, _ = sjson.Set(body, path+"routeMask.value", data.RouteMaskVariable.ValueString()) + } else if data.RouteMask.IsNull() { + body, _ = sjson.Set(body, path+"routeMask.optionType", "default") + body, _ = sjson.Set(body, path+"routeMask.value", "0.0.0.0") + } else { + body, _ = sjson.Set(body, path+"routeMask.optionType", "global") + body, _ = sjson.Set(body, path+"routeMask.value", data.RouteMask.ValueString()) + } + + if !data.VpnVariable.IsNull() { + body, _ = sjson.Set(body, path+"vpn.optionType", "variable") + body, _ = sjson.Set(body, path+"vpn.value", data.VpnVariable.ValueString()) + } else if data.Vpn.IsNull() { + body, _ = sjson.Set(body, path+"vpn.optionType", "default") + + } else { + body, _ = sjson.Set(body, path+"vpn.optionType", "global") + body, _ = sjson.Set(body, path+"vpn.value", data.Vpn.ValueInt64()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *ServiceObjectTracker) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.ObjectTrackerId = types.Int64Null() + data.ObjectTrackerIdVariable = types.StringNull() + if t := res.Get(path + "objectId.optionType"); t.Exists() { + va := res.Get(path + "objectId.value") + if t.String() == "variable" { + data.ObjectTrackerIdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.ObjectTrackerId = types.Int64Value(va.Int()) + } + } + data.ObjectTrackerType = types.StringNull() + + if t := res.Get(path + "objectTrackerType.optionType"); t.Exists() { + va := res.Get(path + "objectTrackerType.value") + if t.String() == "global" { + data.ObjectTrackerType = types.StringValue(va.String()) + } + } + data.Interface = types.StringNull() + data.InterfaceVariable = types.StringNull() + if t := res.Get(path + "interface.optionType"); t.Exists() { + va := res.Get(path + "interface.value") + if t.String() == "variable" { + data.InterfaceVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Interface = types.StringValue(va.String()) + } + } + data.RouteIp = types.StringNull() + data.RouteIpVariable = types.StringNull() + if t := res.Get(path + "routeIp.optionType"); t.Exists() { + va := res.Get(path + "routeIp.value") + if t.String() == "variable" { + data.RouteIpVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.RouteIp = types.StringValue(va.String()) + } + } + data.RouteMask = types.StringNull() + data.RouteMaskVariable = types.StringNull() + if t := res.Get(path + "routeMask.optionType"); t.Exists() { + va := res.Get(path + "routeMask.value") + if t.String() == "variable" { + data.RouteMaskVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.RouteMask = types.StringValue(va.String()) + } + } + data.Vpn = types.Int64Null() + data.VpnVariable = types.StringNull() + if t := res.Get(path + "vpn.optionType"); t.Exists() { + va := res.Get(path + "vpn.value") + if t.String() == "variable" { + data.VpnVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Vpn = types.Int64Value(va.Int()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *ServiceObjectTracker) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.ObjectTrackerId = types.Int64Null() + data.ObjectTrackerIdVariable = types.StringNull() + if t := res.Get(path + "objectId.optionType"); t.Exists() { + va := res.Get(path + "objectId.value") + if t.String() == "variable" { + data.ObjectTrackerIdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.ObjectTrackerId = types.Int64Value(va.Int()) + } + } + data.ObjectTrackerType = types.StringNull() + + if t := res.Get(path + "objectTrackerType.optionType"); t.Exists() { + va := res.Get(path + "objectTrackerType.value") + if t.String() == "global" { + data.ObjectTrackerType = types.StringValue(va.String()) + } + } + data.Interface = types.StringNull() + data.InterfaceVariable = types.StringNull() + if t := res.Get(path + "interface.optionType"); t.Exists() { + va := res.Get(path + "interface.value") + if t.String() == "variable" { + data.InterfaceVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Interface = types.StringValue(va.String()) + } + } + data.RouteIp = types.StringNull() + data.RouteIpVariable = types.StringNull() + if t := res.Get(path + "routeIp.optionType"); t.Exists() { + va := res.Get(path + "routeIp.value") + if t.String() == "variable" { + data.RouteIpVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.RouteIp = types.StringValue(va.String()) + } + } + data.RouteMask = types.StringNull() + data.RouteMaskVariable = types.StringNull() + if t := res.Get(path + "routeMask.optionType"); t.Exists() { + va := res.Get(path + "routeMask.value") + if t.String() == "variable" { + data.RouteMaskVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.RouteMask = types.StringValue(va.String()) + } + } + data.Vpn = types.Int64Null() + data.VpnVariable = types.StringNull() + if t := res.Get(path + "vpn.optionType"); t.Exists() { + va := res.Get(path + "vpn.value") + if t.String() == "variable" { + data.VpnVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Vpn = types.Int64Value(va.Int()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *ServiceObjectTracker) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if !data.ObjectTrackerId.IsNull() { + return false + } + if !data.ObjectTrackerIdVariable.IsNull() { + return false + } + if !data.ObjectTrackerType.IsNull() { + return false + } + if !data.Interface.IsNull() { + return false + } + if !data.InterfaceVariable.IsNull() { + return false + } + if !data.RouteIp.IsNull() { + return false + } + if !data.RouteIpVariable.IsNull() { + return false + } + if !data.RouteMask.IsNull() { + return false + } + if !data.RouteMaskVariable.IsNull() { + return false + } + if !data.Vpn.IsNull() { + return false + } + if !data.VpnVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/model_sdwan_service_tracker_group_profile_parcel.go b/internal/provider/model_sdwan_service_tracker_group_profile_parcel.go new file mode 100644 index 00000000..c45e4a6b --- /dev/null +++ b/internal/provider/model_sdwan_service_tracker_group_profile_parcel.go @@ -0,0 +1,210 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type ServiceTrackerGroup struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + TrackerElements []ServiceTrackerGroupTrackerElements `tfsdk:"tracker_elements"` + TrackerBoolean types.String `tfsdk:"tracker_boolean"` + TrackerBooleanVariable types.String `tfsdk:"tracker_boolean_variable"` +} + +type ServiceTrackerGroupTrackerElements struct { + TrackerId types.String `tfsdk:"tracker_id"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data ServiceTrackerGroup) getModel() string { + return "service_tracker_group" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data ServiceTrackerGroup) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/service/%v/trackergroup", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data ServiceTrackerGroup) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + for _, item := range data.TrackerElements { + itemBody := "" + if !item.TrackerId.IsNull() { + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.value", item.TrackerId.ValueString()) + } + body, _ = sjson.SetRaw(body, path+"trackerRefs.-1", itemBody) + } + + if !data.TrackerBooleanVariable.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "variable") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBooleanVariable.ValueString()) + } else if data.TrackerBoolean.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "default") + body, _ = sjson.Set(body, path+"combineBoolean.value", "or") + } else { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "global") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBoolean.ValueString()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *ServiceTrackerGroup) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + if value := res.Get(path + "trackerRefs"); value.Exists() { + data.TrackerElements = make([]ServiceTrackerGroupTrackerElements, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := ServiceTrackerGroupTrackerElements{} + item.TrackerId = types.StringNull() + + if t := v.Get("trackerRef.refId.optionType"); t.Exists() { + va := v.Get("trackerRef.refId.value") + if t.String() == "global" { + item.TrackerId = types.StringValue(va.String()) + } + } + data.TrackerElements = append(data.TrackerElements, item) + return true + }) + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *ServiceTrackerGroup) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + for i := range data.TrackerElements { + keys := [...]string{"trackerRef.refId"} + keyValues := [...]string{data.TrackerElements[i].TrackerId.ValueString()} + keyValuesVariables := [...]string{""} + + var r gjson.Result + res.Get(path + "trackerRefs").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + tt := v.Get(keys[ik] + ".optionType").String() + vv := v.Get(keys[ik] + ".value").String() + if (tt == "variable" && vv == keyValuesVariables[ik]) || (tt == "global" && vv == keyValues[ik]) { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + data.TrackerElements[i].TrackerId = types.StringNull() + + if t := r.Get("trackerRef.refId.optionType"); t.Exists() { + va := r.Get("trackerRef.refId.value") + if t.String() == "global" { + data.TrackerElements[i].TrackerId = types.StringValue(va.String()) + } + } + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *ServiceTrackerGroup) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if len(data.TrackerElements) > 0 { + return false + } + if !data.TrackerBoolean.IsNull() { + return false + } + if !data.TrackerBooleanVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/model_sdwan_transport_ipv6_tracker_group_profile_parcel.go b/internal/provider/model_sdwan_transport_ipv6_tracker_group_profile_parcel.go new file mode 100644 index 00000000..fb73d4f0 --- /dev/null +++ b/internal/provider/model_sdwan_transport_ipv6_tracker_group_profile_parcel.go @@ -0,0 +1,246 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type TransportIPv6TrackerGroup struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + TrackerName types.String `tfsdk:"tracker_name"` + TrackerNameVariable types.String `tfsdk:"tracker_name_variable"` + TrackerElements []TransportIPv6TrackerGroupTrackerElements `tfsdk:"tracker_elements"` + TrackerBoolean types.String `tfsdk:"tracker_boolean"` + TrackerBooleanVariable types.String `tfsdk:"tracker_boolean_variable"` +} + +type TransportIPv6TrackerGroupTrackerElements struct { + TrackerId types.String `tfsdk:"tracker_id"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data TransportIPv6TrackerGroup) getModel() string { + return "transport_ipv6_tracker_group" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data TransportIPv6TrackerGroup) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/transport/%v/ipv6-trackergroup", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data TransportIPv6TrackerGroup) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + if !data.TrackerNameVariable.IsNull() { + body, _ = sjson.Set(body, path+"trackerGroupName.optionType", "variable") + body, _ = sjson.Set(body, path+"trackerGroupName.value", data.TrackerNameVariable.ValueString()) + } else if !data.TrackerName.IsNull() { + body, _ = sjson.Set(body, path+"trackerGroupName.optionType", "global") + body, _ = sjson.Set(body, path+"trackerGroupName.value", data.TrackerName.ValueString()) + } + + for _, item := range data.TrackerElements { + itemBody := "" + if !item.TrackerId.IsNull() { + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.value", item.TrackerId.ValueString()) + } + body, _ = sjson.SetRaw(body, path+"trackerRefs.-1", itemBody) + } + + if !data.TrackerBooleanVariable.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "variable") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBooleanVariable.ValueString()) + } else if data.TrackerBoolean.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "default") + body, _ = sjson.Set(body, path+"combineBoolean.value", "or") + } else { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "global") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBoolean.ValueString()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *TransportIPv6TrackerGroup) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.TrackerName = types.StringNull() + data.TrackerNameVariable = types.StringNull() + if t := res.Get(path + "trackerGroupName.optionType"); t.Exists() { + va := res.Get(path + "trackerGroupName.value") + if t.String() == "variable" { + data.TrackerNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerName = types.StringValue(va.String()) + } + } + if value := res.Get(path + "trackerRefs"); value.Exists() { + data.TrackerElements = make([]TransportIPv6TrackerGroupTrackerElements, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := TransportIPv6TrackerGroupTrackerElements{} + item.TrackerId = types.StringNull() + + if t := v.Get("trackerRef.refId.optionType"); t.Exists() { + va := v.Get("trackerRef.refId.value") + if t.String() == "global" { + item.TrackerId = types.StringValue(va.String()) + } + } + data.TrackerElements = append(data.TrackerElements, item) + return true + }) + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *TransportIPv6TrackerGroup) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.TrackerName = types.StringNull() + data.TrackerNameVariable = types.StringNull() + if t := res.Get(path + "trackerGroupName.optionType"); t.Exists() { + va := res.Get(path + "trackerGroupName.value") + if t.String() == "variable" { + data.TrackerNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerName = types.StringValue(va.String()) + } + } + for i := range data.TrackerElements { + keys := [...]string{"trackerRef.refId"} + keyValues := [...]string{data.TrackerElements[i].TrackerId.ValueString()} + keyValuesVariables := [...]string{""} + + var r gjson.Result + res.Get(path + "trackerRefs").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + tt := v.Get(keys[ik] + ".optionType").String() + vv := v.Get(keys[ik] + ".value").String() + if (tt == "variable" && vv == keyValuesVariables[ik]) || (tt == "global" && vv == keyValues[ik]) { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + data.TrackerElements[i].TrackerId = types.StringNull() + + if t := r.Get("trackerRef.refId.optionType"); t.Exists() { + va := r.Get("trackerRef.refId.value") + if t.String() == "global" { + data.TrackerElements[i].TrackerId = types.StringValue(va.String()) + } + } + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *TransportIPv6TrackerGroup) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if !data.TrackerName.IsNull() { + return false + } + if !data.TrackerNameVariable.IsNull() { + return false + } + if len(data.TrackerElements) > 0 { + return false + } + if !data.TrackerBoolean.IsNull() { + return false + } + if !data.TrackerBooleanVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/model_sdwan_transport_tracker_group_profile_parcel.go b/internal/provider/model_sdwan_transport_tracker_group_profile_parcel.go new file mode 100644 index 00000000..277679ca --- /dev/null +++ b/internal/provider/model_sdwan_transport_tracker_group_profile_parcel.go @@ -0,0 +1,210 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type TransportTrackerGroup struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + TrackerElements []TransportTrackerGroupTrackerElements `tfsdk:"tracker_elements"` + TrackerBoolean types.String `tfsdk:"tracker_boolean"` + TrackerBooleanVariable types.String `tfsdk:"tracker_boolean_variable"` +} + +type TransportTrackerGroupTrackerElements struct { + TrackerId types.String `tfsdk:"tracker_id"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data TransportTrackerGroup) getModel() string { + return "transport_tracker_group" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data TransportTrackerGroup) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/transport/%v/trackergroup", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data TransportTrackerGroup) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + for _, item := range data.TrackerElements { + itemBody := "" + if !item.TrackerId.IsNull() { + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "trackerRef.refId.value", item.TrackerId.ValueString()) + } + body, _ = sjson.SetRaw(body, path+"trackerRefs.-1", itemBody) + } + + if !data.TrackerBooleanVariable.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "variable") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBooleanVariable.ValueString()) + } else if data.TrackerBoolean.IsNull() { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "default") + body, _ = sjson.Set(body, path+"combineBoolean.value", "or") + } else { + body, _ = sjson.Set(body, path+"combineBoolean.optionType", "global") + body, _ = sjson.Set(body, path+"combineBoolean.value", data.TrackerBoolean.ValueString()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *TransportTrackerGroup) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + if value := res.Get(path + "trackerRefs"); value.Exists() { + data.TrackerElements = make([]TransportTrackerGroupTrackerElements, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := TransportTrackerGroupTrackerElements{} + item.TrackerId = types.StringNull() + + if t := v.Get("trackerRef.refId.optionType"); t.Exists() { + va := v.Get("trackerRef.refId.value") + if t.String() == "global" { + item.TrackerId = types.StringValue(va.String()) + } + } + data.TrackerElements = append(data.TrackerElements, item) + return true + }) + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *TransportTrackerGroup) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + for i := range data.TrackerElements { + keys := [...]string{"trackerRef.refId"} + keyValues := [...]string{data.TrackerElements[i].TrackerId.ValueString()} + keyValuesVariables := [...]string{""} + + var r gjson.Result + res.Get(path + "trackerRefs").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + tt := v.Get(keys[ik] + ".optionType").String() + vv := v.Get(keys[ik] + ".value").String() + if (tt == "variable" && vv == keyValuesVariables[ik]) || (tt == "global" && vv == keyValues[ik]) { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + data.TrackerElements[i].TrackerId = types.StringNull() + + if t := r.Get("trackerRef.refId.optionType"); t.Exists() { + va := r.Get("trackerRef.refId.value") + if t.String() == "global" { + data.TrackerElements[i].TrackerId = types.StringValue(va.String()) + } + } + } + data.TrackerBoolean = types.StringNull() + data.TrackerBooleanVariable = types.StringNull() + if t := res.Get(path + "combineBoolean.optionType"); t.Exists() { + va := res.Get(path + "combineBoolean.value") + if t.String() == "variable" { + data.TrackerBooleanVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerBoolean = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *TransportTrackerGroup) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if len(data.TrackerElements) > 0 { + return false + } + if !data.TrackerBoolean.IsNull() { + return false + } + if !data.TrackerBooleanVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/model_sdwan_transport_tracker_profile_parcel.go b/internal/provider/model_sdwan_transport_tracker_profile_parcel.go new file mode 100644 index 00000000..47f0e65a --- /dev/null +++ b/internal/provider/model_sdwan_transport_tracker_profile_parcel.go @@ -0,0 +1,442 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin types +type TransportTracker struct { + Id types.String `tfsdk:"id"` + Version types.Int64 `tfsdk:"version"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + FeatureProfileId types.String `tfsdk:"feature_profile_id"` + TrackerName types.String `tfsdk:"tracker_name"` + TrackerNameVariable types.String `tfsdk:"tracker_name_variable"` + EndpointApiUrl types.String `tfsdk:"endpoint_api_url"` + EndpointApiUrlVariable types.String `tfsdk:"endpoint_api_url_variable"` + EndpointDnsName types.String `tfsdk:"endpoint_dns_name"` + EndpointDnsNameVariable types.String `tfsdk:"endpoint_dns_name_variable"` + EndpointIp types.String `tfsdk:"endpoint_ip"` + EndpointIpVariable types.String `tfsdk:"endpoint_ip_variable"` + Interval types.Int64 `tfsdk:"interval"` + IntervalVariable types.String `tfsdk:"interval_variable"` + Multiplier types.Int64 `tfsdk:"multiplier"` + MultiplierVariable types.String `tfsdk:"multiplier_variable"` + Threshold types.Int64 `tfsdk:"threshold"` + ThresholdVariable types.String `tfsdk:"threshold_variable"` + EndpointTrackerType types.String `tfsdk:"endpoint_tracker_type"` + EndpointTrackerTypeVariable types.String `tfsdk:"endpoint_tracker_type_variable"` + TrackerType types.String `tfsdk:"tracker_type"` + TrackerTypeVariable types.String `tfsdk:"tracker_type_variable"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data TransportTracker) getModel() string { + return "transport_tracker" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data TransportTracker) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/transport/%v/tracker", url.QueryEscape(data.FeatureProfileId.ValueString())) +} + +// End of section. //template:end getPath + +// Section below is generated&owned by "gen/generator.go". //template:begin toBody +func (data TransportTracker) toBody(ctx context.Context) string { + body := "" + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + path := "data." + + if !data.TrackerNameVariable.IsNull() { + body, _ = sjson.Set(body, path+"trackerName.optionType", "variable") + body, _ = sjson.Set(body, path+"trackerName.value", data.TrackerNameVariable.ValueString()) + } else if !data.TrackerName.IsNull() { + body, _ = sjson.Set(body, path+"trackerName.optionType", "global") + body, _ = sjson.Set(body, path+"trackerName.value", data.TrackerName.ValueString()) + } + + if !data.EndpointApiUrlVariable.IsNull() { + body, _ = sjson.Set(body, path+"endpointApiUrl.optionType", "variable") + body, _ = sjson.Set(body, path+"endpointApiUrl.value", data.EndpointApiUrlVariable.ValueString()) + } else if !data.EndpointApiUrl.IsNull() { + body, _ = sjson.Set(body, path+"endpointApiUrl.optionType", "global") + body, _ = sjson.Set(body, path+"endpointApiUrl.value", data.EndpointApiUrl.ValueString()) + } + + if !data.EndpointDnsNameVariable.IsNull() { + body, _ = sjson.Set(body, path+"endpointDnsName.optionType", "variable") + body, _ = sjson.Set(body, path+"endpointDnsName.value", data.EndpointDnsNameVariable.ValueString()) + } else if !data.EndpointDnsName.IsNull() { + body, _ = sjson.Set(body, path+"endpointDnsName.optionType", "global") + body, _ = sjson.Set(body, path+"endpointDnsName.value", data.EndpointDnsName.ValueString()) + } + + if !data.EndpointIpVariable.IsNull() { + body, _ = sjson.Set(body, path+"endpointIp.optionType", "variable") + body, _ = sjson.Set(body, path+"endpointIp.value", data.EndpointIpVariable.ValueString()) + } else if !data.EndpointIp.IsNull() { + body, _ = sjson.Set(body, path+"endpointIp.optionType", "global") + body, _ = sjson.Set(body, path+"endpointIp.value", data.EndpointIp.ValueString()) + } + + if !data.IntervalVariable.IsNull() { + body, _ = sjson.Set(body, path+"interval.optionType", "variable") + body, _ = sjson.Set(body, path+"interval.value", data.IntervalVariable.ValueString()) + } else if data.Interval.IsNull() { + body, _ = sjson.Set(body, path+"interval.optionType", "default") + body, _ = sjson.Set(body, path+"interval.value", 60) + } else { + body, _ = sjson.Set(body, path+"interval.optionType", "global") + body, _ = sjson.Set(body, path+"interval.value", data.Interval.ValueInt64()) + } + + if !data.MultiplierVariable.IsNull() { + body, _ = sjson.Set(body, path+"multiplier.optionType", "variable") + body, _ = sjson.Set(body, path+"multiplier.value", data.MultiplierVariable.ValueString()) + } else if data.Multiplier.IsNull() { + body, _ = sjson.Set(body, path+"multiplier.optionType", "default") + body, _ = sjson.Set(body, path+"multiplier.value", 3) + } else { + body, _ = sjson.Set(body, path+"multiplier.optionType", "global") + body, _ = sjson.Set(body, path+"multiplier.value", data.Multiplier.ValueInt64()) + } + + if !data.ThresholdVariable.IsNull() { + body, _ = sjson.Set(body, path+"threshold.optionType", "variable") + body, _ = sjson.Set(body, path+"threshold.value", data.ThresholdVariable.ValueString()) + } else if data.Threshold.IsNull() { + body, _ = sjson.Set(body, path+"threshold.optionType", "default") + body, _ = sjson.Set(body, path+"threshold.value", 300) + } else { + body, _ = sjson.Set(body, path+"threshold.optionType", "global") + body, _ = sjson.Set(body, path+"threshold.value", data.Threshold.ValueInt64()) + } + + if !data.EndpointTrackerTypeVariable.IsNull() { + body, _ = sjson.Set(body, path+"endpointTrackerType.optionType", "variable") + body, _ = sjson.Set(body, path+"endpointTrackerType.value", data.EndpointTrackerTypeVariable.ValueString()) + } else if data.EndpointTrackerType.IsNull() { + body, _ = sjson.Set(body, path+"endpointTrackerType.optionType", "default") + body, _ = sjson.Set(body, path+"endpointTrackerType.value", "interface") + } else { + body, _ = sjson.Set(body, path+"endpointTrackerType.optionType", "global") + body, _ = sjson.Set(body, path+"endpointTrackerType.value", data.EndpointTrackerType.ValueString()) + } + + if !data.TrackerTypeVariable.IsNull() { + body, _ = sjson.Set(body, path+"trackerType.optionType", "variable") + body, _ = sjson.Set(body, path+"trackerType.value", data.TrackerTypeVariable.ValueString()) + } else if data.TrackerType.IsNull() { + body, _ = sjson.Set(body, path+"trackerType.optionType", "default") + body, _ = sjson.Set(body, path+"trackerType.value", "endpoint") + } else { + body, _ = sjson.Set(body, path+"trackerType.optionType", "global") + body, _ = sjson.Set(body, path+"trackerType.value", data.TrackerType.ValueString()) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *TransportTracker) fromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.TrackerName = types.StringNull() + data.TrackerNameVariable = types.StringNull() + if t := res.Get(path + "trackerName.optionType"); t.Exists() { + va := res.Get(path + "trackerName.value") + if t.String() == "variable" { + data.TrackerNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerName = types.StringValue(va.String()) + } + } + data.EndpointApiUrl = types.StringNull() + data.EndpointApiUrlVariable = types.StringNull() + if t := res.Get(path + "endpointApiUrl.optionType"); t.Exists() { + va := res.Get(path + "endpointApiUrl.value") + if t.String() == "variable" { + data.EndpointApiUrlVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointApiUrl = types.StringValue(va.String()) + } + } + data.EndpointDnsName = types.StringNull() + data.EndpointDnsNameVariable = types.StringNull() + if t := res.Get(path + "endpointDnsName.optionType"); t.Exists() { + va := res.Get(path + "endpointDnsName.value") + if t.String() == "variable" { + data.EndpointDnsNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointDnsName = types.StringValue(va.String()) + } + } + data.EndpointIp = types.StringNull() + data.EndpointIpVariable = types.StringNull() + if t := res.Get(path + "endpointIp.optionType"); t.Exists() { + va := res.Get(path + "endpointIp.value") + if t.String() == "variable" { + data.EndpointIpVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointIp = types.StringValue(va.String()) + } + } + data.Interval = types.Int64Null() + data.IntervalVariable = types.StringNull() + if t := res.Get(path + "interval.optionType"); t.Exists() { + va := res.Get(path + "interval.value") + if t.String() == "variable" { + data.IntervalVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Interval = types.Int64Value(va.Int()) + } + } + data.Multiplier = types.Int64Null() + data.MultiplierVariable = types.StringNull() + if t := res.Get(path + "multiplier.optionType"); t.Exists() { + va := res.Get(path + "multiplier.value") + if t.String() == "variable" { + data.MultiplierVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Multiplier = types.Int64Value(va.Int()) + } + } + data.Threshold = types.Int64Null() + data.ThresholdVariable = types.StringNull() + if t := res.Get(path + "threshold.optionType"); t.Exists() { + va := res.Get(path + "threshold.value") + if t.String() == "variable" { + data.ThresholdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Threshold = types.Int64Value(va.Int()) + } + } + data.EndpointTrackerType = types.StringNull() + data.EndpointTrackerTypeVariable = types.StringNull() + if t := res.Get(path + "endpointTrackerType.optionType"); t.Exists() { + va := res.Get(path + "endpointTrackerType.value") + if t.String() == "variable" { + data.EndpointTrackerTypeVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointTrackerType = types.StringValue(va.String()) + } + } + data.TrackerType = types.StringNull() + data.TrackerTypeVariable = types.StringNull() + if t := res.Get(path + "trackerType.optionType"); t.Exists() { + va := res.Get(path + "trackerType.value") + if t.String() == "variable" { + data.TrackerTypeVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerType = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *TransportTracker) updateFromBody(ctx context.Context, res gjson.Result) { + data.Name = types.StringValue(res.Get("payload.name").String()) + if value := res.Get("payload.description"); value.Exists() && value.String() != "" { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + path := "payload.data." + data.TrackerName = types.StringNull() + data.TrackerNameVariable = types.StringNull() + if t := res.Get(path + "trackerName.optionType"); t.Exists() { + va := res.Get(path + "trackerName.value") + if t.String() == "variable" { + data.TrackerNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerName = types.StringValue(va.String()) + } + } + data.EndpointApiUrl = types.StringNull() + data.EndpointApiUrlVariable = types.StringNull() + if t := res.Get(path + "endpointApiUrl.optionType"); t.Exists() { + va := res.Get(path + "endpointApiUrl.value") + if t.String() == "variable" { + data.EndpointApiUrlVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointApiUrl = types.StringValue(va.String()) + } + } + data.EndpointDnsName = types.StringNull() + data.EndpointDnsNameVariable = types.StringNull() + if t := res.Get(path + "endpointDnsName.optionType"); t.Exists() { + va := res.Get(path + "endpointDnsName.value") + if t.String() == "variable" { + data.EndpointDnsNameVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointDnsName = types.StringValue(va.String()) + } + } + data.EndpointIp = types.StringNull() + data.EndpointIpVariable = types.StringNull() + if t := res.Get(path + "endpointIp.optionType"); t.Exists() { + va := res.Get(path + "endpointIp.value") + if t.String() == "variable" { + data.EndpointIpVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointIp = types.StringValue(va.String()) + } + } + data.Interval = types.Int64Null() + data.IntervalVariable = types.StringNull() + if t := res.Get(path + "interval.optionType"); t.Exists() { + va := res.Get(path + "interval.value") + if t.String() == "variable" { + data.IntervalVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Interval = types.Int64Value(va.Int()) + } + } + data.Multiplier = types.Int64Null() + data.MultiplierVariable = types.StringNull() + if t := res.Get(path + "multiplier.optionType"); t.Exists() { + va := res.Get(path + "multiplier.value") + if t.String() == "variable" { + data.MultiplierVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Multiplier = types.Int64Value(va.Int()) + } + } + data.Threshold = types.Int64Null() + data.ThresholdVariable = types.StringNull() + if t := res.Get(path + "threshold.optionType"); t.Exists() { + va := res.Get(path + "threshold.value") + if t.String() == "variable" { + data.ThresholdVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.Threshold = types.Int64Value(va.Int()) + } + } + data.EndpointTrackerType = types.StringNull() + data.EndpointTrackerTypeVariable = types.StringNull() + if t := res.Get(path + "endpointTrackerType.optionType"); t.Exists() { + va := res.Get(path + "endpointTrackerType.value") + if t.String() == "variable" { + data.EndpointTrackerTypeVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.EndpointTrackerType = types.StringValue(va.String()) + } + } + data.TrackerType = types.StringNull() + data.TrackerTypeVariable = types.StringNull() + if t := res.Get(path + "trackerType.optionType"); t.Exists() { + va := res.Get(path + "trackerType.value") + if t.String() == "variable" { + data.TrackerTypeVariable = types.StringValue(va.String()) + } else if t.String() == "global" { + data.TrackerType = types.StringValue(va.String()) + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *TransportTracker) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if !data.TrackerName.IsNull() { + return false + } + if !data.TrackerNameVariable.IsNull() { + return false + } + if !data.EndpointApiUrl.IsNull() { + return false + } + if !data.EndpointApiUrlVariable.IsNull() { + return false + } + if !data.EndpointDnsName.IsNull() { + return false + } + if !data.EndpointDnsNameVariable.IsNull() { + return false + } + if !data.EndpointIp.IsNull() { + return false + } + if !data.EndpointIpVariable.IsNull() { + return false + } + if !data.Interval.IsNull() { + return false + } + if !data.IntervalVariable.IsNull() { + return false + } + if !data.Multiplier.IsNull() { + return false + } + if !data.MultiplierVariable.IsNull() { + return false + } + if !data.Threshold.IsNull() { + return false + } + if !data.ThresholdVariable.IsNull() { + return false + } + if !data.EndpointTrackerType.IsNull() { + return false + } + if !data.EndpointTrackerTypeVariable.IsNull() { + return false + } + if !data.TrackerType.IsNull() { + return false + } + if !data.TrackerTypeVariable.IsNull() { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/provider.go b/internal/provider/provider.go index c9ea78d2..a4a579a5 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -288,7 +288,10 @@ func (p *SdwanProvider) Resources(ctx context.Context) []func() resource.Resourc NewServiceLANVPNInterfaceGREProfileParcelResource, NewServiceLANVPNInterfaceIPSecProfileParcelResource, NewServiceLANVPNInterfaceSVIProfileParcelResource, + NewServiceObjectTrackerProfileParcelResource, + NewServiceObjectTrackerGroupProfileParcelResource, NewServiceTrackerProfileParcelResource, + NewServiceTrackerGroupProfileParcelResource, NewSystemAAAProfileParcelResource, NewSystemBannerProfileParcelResource, NewSystemBasicProfileParcelResource, @@ -306,9 +309,12 @@ func (p *SdwanProvider) Resources(ctx context.Context) []func() resource.Resourc NewSystemSecurityProfileParcelResource, NewSystemSNMPProfileParcelResource, NewTransportIPv6TrackerProfileParcelResource, + NewTransportIPv6TrackerGroupProfileParcelResource, NewTransportManagementVPNProfileParcelResource, NewTransportManagementVPNInterfaceEthernetProfileParcelResource, NewTransportRoutingBGPProfileParcelResource, + NewTransportTrackerProfileParcelResource, + NewTransportTrackerGroupProfileParcelResource, NewTransportWANVPNProfileParcelResource, NewTransportWANVPNInterfaceCellularProfileParcelResource, NewTransportWANVPNInterfaceEthernetProfileParcelResource, @@ -436,7 +442,10 @@ func (p *SdwanProvider) DataSources(ctx context.Context) []func() datasource.Dat NewServiceLANVPNInterfaceGREProfileParcelDataSource, NewServiceLANVPNInterfaceIPSecProfileParcelDataSource, NewServiceLANVPNInterfaceSVIProfileParcelDataSource, + NewServiceObjectTrackerProfileParcelDataSource, + NewServiceObjectTrackerGroupProfileParcelDataSource, NewServiceTrackerProfileParcelDataSource, + NewServiceTrackerGroupProfileParcelDataSource, NewSystemAAAProfileParcelDataSource, NewSystemBannerProfileParcelDataSource, NewSystemBasicProfileParcelDataSource, @@ -454,9 +463,12 @@ func (p *SdwanProvider) DataSources(ctx context.Context) []func() datasource.Dat NewSystemSecurityProfileParcelDataSource, NewSystemSNMPProfileParcelDataSource, NewTransportIPv6TrackerProfileParcelDataSource, + NewTransportIPv6TrackerGroupProfileParcelDataSource, NewTransportManagementVPNProfileParcelDataSource, NewTransportManagementVPNInterfaceEthernetProfileParcelDataSource, NewTransportRoutingBGPProfileParcelDataSource, + NewTransportTrackerProfileParcelDataSource, + NewTransportTrackerGroupProfileParcelDataSource, NewTransportWANVPNProfileParcelDataSource, NewTransportWANVPNInterfaceCellularProfileParcelDataSource, NewTransportWANVPNInterfaceEthernetProfileParcelDataSource, diff --git a/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel.go b/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel.go new file mode 100644 index 00000000..96fe895b --- /dev/null +++ b/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel.go @@ -0,0 +1,281 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &ServiceObjectTrackerGroupProfileParcelResource{} +var _ resource.ResourceWithImportState = &ServiceObjectTrackerGroupProfileParcelResource{} + +func NewServiceObjectTrackerGroupProfileParcelResource() resource.Resource { + return &ServiceObjectTrackerGroupProfileParcelResource{} +} + +type ServiceObjectTrackerGroupProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *ServiceObjectTrackerGroupProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_object_tracker_group_profile_parcel" +} + +func (r *ServiceObjectTrackerGroupProfileParcelResource) 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 Service Object Tracker Group profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "object_tracker_id": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Object ID").AddIntegerRangeDescription(1, 1000).String, + Required: true, + Validators: []validator.Int64{ + int64validator.Between(1, 1000), + }, + }, + "object_tracker_id_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Group Tracks ID Refs").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "object_tracker_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`), ""), + }, + }, + }, + }, + }, + "reachable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker ref list criteria boolean and or").AddStringEnumDescription("and", "or").AddDefaultValueDescription("or").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("and", "or"), + }, + }, + "reachable_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + }, + } +} + +func (r *ServiceObjectTrackerGroupProfileParcelResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*SdwanProviderData).Client + r.updateMutex = req.ProviderData.(*SdwanProviderData).UpdateMutex +} + +// End of section. //template:end model + +// Section below is generated&owned by "gen/generator.go". //template:begin create +func (r *ServiceObjectTrackerGroupProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ServiceObjectTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + + // Create object + body := plan.toBody(ctx) + + 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("parcelId").String()) + plan.Version = types.Int64Value(0) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end create + +// Section below is generated&owned by "gen/generator.go". //template:begin read +func (r *ServiceObjectTrackerGroupProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ServiceObjectTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) + if res.Get("error.message").String() == "Invalid feature Id" { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + // If every attribute is set to null we are dealing with an import operation and therefore reading all attributes + if state.isNull(ctx, res) { + state.fromBody(ctx, res) + } else { + state.updateFromBody(ctx, res) + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Name.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read + +// Section below is generated&owned by "gen/generator.go". //template:begin update +func (r *ServiceObjectTrackerGroupProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ServiceObjectTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) + + body := plan.toBody(ctx) + 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 + } + + plan.Version = types.Int64Value(state.Version.ValueInt64() + 1) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end update + +// Section below is generated&owned by "gen/generator.go". //template:begin delete +func (r *ServiceObjectTrackerGroupProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ServiceObjectTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + 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 && res.Get("error.message").String() != "Invalid Template Id" { + 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 *ServiceObjectTrackerGroupProfileParcelResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +// End of section. //template:end import diff --git a/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel_test.go b/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..4eb99958 --- /dev/null +++ b/internal/provider/resource_sdwan_service_object_tracker_group_profile_parcel_test.go @@ -0,0 +1,101 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAcc +func TestAccSdwanServiceObjectTrackerGroupProfileParcel(t *testing.T) { + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_object_tracker_group_profile_parcel.test", "reachable", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + + { + Config: testAccSdwanServiceObjectTrackerGroupPrerequisitesProfileParcelConfig + testAccSdwanServiceObjectTrackerGroupProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanServiceObjectTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_service_object_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 11 + tracker_type = "Interface" + interface = "GigabitEthernet1" +} + +resource "sdwan_service_object_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "My Example" + feature_profile_id = sdwan_service_feature_profile.test.id + object_tracker_id = 12 + tracker_type = "Interface" + interface = "GigabitEthernet1" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanServiceObjectTrackerGroupProfileParcelConfig_all() string { + config := `resource "sdwan_service_object_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` object_tracker_id = 10` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` object_tracker_id = sdwan_service_object_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` object_tracker_id = sdwan_service_object_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` reachable = "or"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/internal/provider/resource_sdwan_service_object_tracker_profile_parcel.go b/internal/provider/resource_sdwan_service_object_tracker_profile_parcel.go new file mode 100644 index 00000000..1ebc1fc0 --- /dev/null +++ b/internal/provider/resource_sdwan_service_object_tracker_profile_parcel.go @@ -0,0 +1,301 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &ServiceObjectTrackerProfileParcelResource{} +var _ resource.ResourceWithImportState = &ServiceObjectTrackerProfileParcelResource{} + +func NewServiceObjectTrackerProfileParcelResource() resource.Resource { + return &ServiceObjectTrackerProfileParcelResource{} +} + +type ServiceObjectTrackerProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *ServiceObjectTrackerProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_object_tracker_profile_parcel" +} + +func (r *ServiceObjectTrackerProfileParcelResource) 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 Service Object Tracker profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "object_tracker_id": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Object tracker ID").AddIntegerRangeDescription(1, 1000).String, + Required: true, + Validators: []validator.Int64{ + int64validator.Between(1, 1000), + }, + }, + "object_tracker_id_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "object_tracker_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("objectTrackerType:Interface SIG Route").AddStringEnumDescription("Interface", "SIG", "Route").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("Interface", "SIG", "Route"), + }, + }, + "interface": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("interface name").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(3, 32), + stringvalidator.RegexMatches(regexp.MustCompile(`(ATM|ATM-ACR|AppGigabitEthernet|AppNav-Compress|AppNav-UnCompress|Async|BD-VIF|BDI|CEM|CEM-ACR|Cellular|Dialer|Embedded-Service-Engine|Ethernet|Ethernet-Internal|FastEthernet|FiftyGigabitEthernet|FiveGigabitEthernet|FortyGigabitEthernet|FourHundredGigE|GMPLS|GigabitEthernet|Group-Async|HundredGigE|L2LISP|LISP|Loopback|MFR|Multilink|Port-channel|SM|Serial|Service-Engine|TenGigabitEthernet|Tunnel|TwentyFiveGigE|TwentyFiveGigabitEthernet|TwoGigabitEthernet|TwoHundredGigE|Vif|Virtual-PPP|Virtual-Template|VirtualPortGroup|Vlan|Wlan-GigabitEthernet|nat64|nat66|ntp|nve|ospfv3|overlay|pseudowire|ucse|vasileft|vasiright|vmi)([0-9]*(. ?[1-9][0-9]*)*|[0-9/]+|[0-9]+/[0-9]+/[0-9]+:[0-9]+|[0-9]+/[0-9]+/[0-9]+|[0-9]+/[0-9]+|[0-9]+)`), ""), + }, + }, + "interface_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "route_ip": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IP address").String, + Optional: true, + }, + "route_ip_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "route_mask": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IP mask").AddStringEnumDescription("255.255.255.255", "255.255.255.254", "255.255.255.252", "255.255.255.248", "255.255.255.240", "255.255.255.224", "255.255.255.192", "255.255.255.128", "255.255.255.0", "255.255.254.0", "255.255.252.0", "255.255.248.0", "255.255.240.0", "255.255.224.0", "255.255.192.0", "255.255.128.0", "255.255.0.0", "255.254.0.0", "255.252.0.0", "255.240.0.0", "255.224.0.0", "255.192.0.0", "255.128.0.0", "255.0.0.0", "254.0.0.0", "252.0.0.0", "248.0.0.0", "240.0.0.0", "224.0.0.0", "192.0.0.0", "128.0.0.0", "0.0.0.0").AddDefaultValueDescription("0.0.0.0").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("255.255.255.255", "255.255.255.254", "255.255.255.252", "255.255.255.248", "255.255.255.240", "255.255.255.224", "255.255.255.192", "255.255.255.128", "255.255.255.0", "255.255.254.0", "255.255.252.0", "255.255.248.0", "255.255.240.0", "255.255.224.0", "255.255.192.0", "255.255.128.0", "255.255.0.0", "255.254.0.0", "255.252.0.0", "255.240.0.0", "255.224.0.0", "255.192.0.0", "255.128.0.0", "255.0.0.0", "254.0.0.0", "252.0.0.0", "248.0.0.0", "240.0.0.0", "224.0.0.0", "192.0.0.0", "128.0.0.0", "0.0.0.0"), + }, + }, + "route_mask_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "vpn": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("VPN").AddIntegerRangeDescription(0, 65530).String, + Optional: true, + }, + "vpn_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + }, + } +} + +func (r *ServiceObjectTrackerProfileParcelResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*SdwanProviderData).Client + r.updateMutex = req.ProviderData.(*SdwanProviderData).UpdateMutex +} + +// End of section. //template:end model + +// Section below is generated&owned by "gen/generator.go". //template:begin create +func (r *ServiceObjectTrackerProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ServiceObjectTracker + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + + // Create object + body := plan.toBody(ctx) + + 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("parcelId").String()) + plan.Version = types.Int64Value(0) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end create + +// Section below is generated&owned by "gen/generator.go". //template:begin read +func (r *ServiceObjectTrackerProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ServiceObjectTracker + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) + if res.Get("error.message").String() == "Invalid feature Id" { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + // If every attribute is set to null we are dealing with an import operation and therefore reading all attributes + if state.isNull(ctx, res) { + state.fromBody(ctx, res) + } else { + state.updateFromBody(ctx, res) + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Name.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read + +// Section below is generated&owned by "gen/generator.go". //template:begin update +func (r *ServiceObjectTrackerProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ServiceObjectTracker + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) + + body := plan.toBody(ctx) + 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 + } + + plan.Version = types.Int64Value(state.Version.ValueInt64() + 1) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end update + +// Section below is generated&owned by "gen/generator.go". //template:begin delete +func (r *ServiceObjectTrackerProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ServiceObjectTracker + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + 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 && res.Get("error.message").String() != "Invalid Template Id" { + 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 *ServiceObjectTrackerProfileParcelResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +// End of section. //template:end import diff --git a/internal/provider/resource_sdwan_service_object_tracker_profile_parcel_test.go b/internal/provider/resource_sdwan_service_object_tracker_profile_parcel_test.go new file mode 100644 index 00000000..ac939670 --- /dev/null +++ b/internal/provider/resource_sdwan_service_object_tracker_profile_parcel_test.go @@ -0,0 +1,94 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAcc +func TestAccSdwanServiceObjectTrackerProfileParcel(t *testing.T) { + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_object_tracker_profile_parcel.test", "object_tracker_type", "Interface")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_object_tracker_profile_parcel.test", "interface", "GigabitEthernet1")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccSdwanServiceObjectTrackerPrerequisitesProfileParcelConfig + testAccSdwanServiceObjectTrackerProfileParcelConfig_minimum(), + }, + { + Config: testAccSdwanServiceObjectTrackerPrerequisitesProfileParcelConfig + testAccSdwanServiceObjectTrackerProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanServiceObjectTrackerPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum +func testAccSdwanServiceObjectTrackerProfileParcelConfig_minimum() string { + config := `resource "sdwan_service_object_tracker_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_MIN"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` object_tracker_id = 10` + "\n" + config += ` object_tracker_type = "Interface"` + "\n" + config += ` interface = "GigabitEthernet1"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanServiceObjectTrackerProfileParcelConfig_all() string { + config := `resource "sdwan_service_object_tracker_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` object_tracker_id = 10` + "\n" + config += ` object_tracker_type = "Interface"` + "\n" + config += ` interface = "GigabitEthernet1"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/internal/provider/resource_sdwan_service_tracker_group_profile_parcel.go b/internal/provider/resource_sdwan_service_tracker_group_profile_parcel.go new file mode 100644 index 00000000..f85e09ff --- /dev/null +++ b/internal/provider/resource_sdwan_service_tracker_group_profile_parcel.go @@ -0,0 +1,269 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &ServiceTrackerGroupProfileParcelResource{} +var _ resource.ResourceWithImportState = &ServiceTrackerGroupProfileParcelResource{} + +func NewServiceTrackerGroupProfileParcelResource() resource.Resource { + return &ServiceTrackerGroupProfileParcelResource{} +} + +type ServiceTrackerGroupProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *ServiceTrackerGroupProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_tracker_group_profile_parcel" +} + +func (r *ServiceTrackerGroupProfileParcelResource) 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 Service Tracker Group profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker parcel ref list").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`), ""), + }, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker ref list combine boolean and or").AddStringEnumDescription("and", "or").AddDefaultValueDescription("or").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("and", "or"), + }, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + }, + } +} + +func (r *ServiceTrackerGroupProfileParcelResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*SdwanProviderData).Client + r.updateMutex = req.ProviderData.(*SdwanProviderData).UpdateMutex +} + +// End of section. //template:end model + +// Section below is generated&owned by "gen/generator.go". //template:begin create +func (r *ServiceTrackerGroupProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ServiceTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + + // Create object + body := plan.toBody(ctx) + + 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("parcelId").String()) + plan.Version = types.Int64Value(0) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end create + +// Section below is generated&owned by "gen/generator.go". //template:begin read +func (r *ServiceTrackerGroupProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ServiceTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) + if res.Get("error.message").String() == "Invalid feature Id" { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + // If every attribute is set to null we are dealing with an import operation and therefore reading all attributes + if state.isNull(ctx, res) { + state.fromBody(ctx, res) + } else { + state.updateFromBody(ctx, res) + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Name.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read + +// Section below is generated&owned by "gen/generator.go". //template:begin update +func (r *ServiceTrackerGroupProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ServiceTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) + + body := plan.toBody(ctx) + 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 + } + + plan.Version = types.Int64Value(state.Version.ValueInt64() + 1) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end update + +// Section below is generated&owned by "gen/generator.go". //template:begin delete +func (r *ServiceTrackerGroupProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ServiceTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + 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 && res.Get("error.message").String() != "Invalid Template Id" { + 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 *ServiceTrackerGroupProfileParcelResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +// End of section. //template:end import diff --git a/internal/provider/resource_sdwan_service_tracker_group_profile_parcel_test.go b/internal/provider/resource_sdwan_service_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..38c09302 --- /dev/null +++ b/internal/provider/resource_sdwan_service_tracker_group_profile_parcel_test.go @@ -0,0 +1,116 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAcc +func TestAccSdwanServiceTrackerGroupProfileParcel(t *testing.T) { + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + + { + Config: testAccSdwanServiceTrackerGroupPrerequisitesProfileParcelConfig + testAccSdwanServiceTrackerGroupProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanServiceTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_service_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_service_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" +} + +resource "sdwan_service_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform test" + feature_profile_id = sdwan_service_feature_profile.test.id + tracker_name = "TRACKER_2" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + protocol = "tcp" + port = 123 + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "static-route" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanServiceTrackerGroupProfileParcelConfig_all() string { + config := `resource "sdwan_service_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_service_feature_profile.test.id` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_service_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_service_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel.go b/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel.go new file mode 100644 index 00000000..57ade3d4 --- /dev/null +++ b/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel.go @@ -0,0 +1,280 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &TransportIPv6TrackerGroupProfileParcelResource{} +var _ resource.ResourceWithImportState = &TransportIPv6TrackerGroupProfileParcelResource{} + +func NewTransportIPv6TrackerGroupProfileParcelResource() resource.Resource { + return &TransportIPv6TrackerGroupProfileParcelResource{} +} + +type TransportIPv6TrackerGroupProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *TransportIPv6TrackerGroupProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_ipv6_tracker_group_profile_parcel" +} + +func (r *TransportIPv6TrackerGroupProfileParcelResource) 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 Transport IPv6 Tracker Group profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "tracker_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Tracker Name").String, + Required: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 128), + }, + }, + "tracker_name_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("trackers ref list").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`), ""), + }, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker ref list combine boolean and or").AddStringEnumDescription("and", "or").AddDefaultValueDescription("or").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("and", "or"), + }, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + }, + } +} + +func (r *TransportIPv6TrackerGroupProfileParcelResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*SdwanProviderData).Client + r.updateMutex = req.ProviderData.(*SdwanProviderData).UpdateMutex +} + +// End of section. //template:end model + +// Section below is generated&owned by "gen/generator.go". //template:begin create +func (r *TransportIPv6TrackerGroupProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan TransportIPv6TrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + + // Create object + body := plan.toBody(ctx) + + 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("parcelId").String()) + plan.Version = types.Int64Value(0) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end create + +// Section below is generated&owned by "gen/generator.go". //template:begin read +func (r *TransportIPv6TrackerGroupProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state TransportIPv6TrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) + if res.Get("error.message").String() == "Invalid feature Id" { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + // If every attribute is set to null we are dealing with an import operation and therefore reading all attributes + if state.isNull(ctx, res) { + state.fromBody(ctx, res) + } else { + state.updateFromBody(ctx, res) + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Name.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read + +// Section below is generated&owned by "gen/generator.go". //template:begin update +func (r *TransportIPv6TrackerGroupProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state TransportIPv6TrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) + + body := plan.toBody(ctx) + 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 + } + + plan.Version = types.Int64Value(state.Version.ValueInt64() + 1) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end update + +// Section below is generated&owned by "gen/generator.go". //template:begin delete +func (r *TransportIPv6TrackerGroupProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state TransportIPv6TrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + 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 && res.Get("error.message").String() != "Invalid Template Id" { + 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 *TransportIPv6TrackerGroupProfileParcelResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +// End of section. //template:end import diff --git a/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go b/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..1196de90 --- /dev/null +++ b/internal/provider/resource_sdwan_transport_ipv6_tracker_group_profile_parcel_test.go @@ -0,0 +1,114 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAcc +func TestAccSdwanTransportIPv6TrackerGroupProfileParcel(t *testing.T) { + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_ipv6_tracker_group_profile_parcel.test", "tracker_name", "TRACKER_GROUP_1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_ipv6_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + + { + Config: testAccSdwanTransportIPv6TrackerGroupPrerequisitesProfileParcelConfig + testAccSdwanTransportIPv6TrackerGroupProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanTransportIPv6TrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" +} + +resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "2001:0:0:1::0" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "ipv6-interface" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanTransportIPv6TrackerGroupProfileParcelConfig_all() string { + config := `resource "sdwan_transport_ipv6_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_transport_feature_profile.test.id` + "\n" + config += ` tracker_name = "TRACKER_GROUP_1"` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_transport_ipv6_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_transport_ipv6_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel.go b/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel.go new file mode 100644 index 00000000..07afb3fc --- /dev/null +++ b/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel.go @@ -0,0 +1,269 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &TransportTrackerGroupProfileParcelResource{} +var _ resource.ResourceWithImportState = &TransportTrackerGroupProfileParcelResource{} + +func NewTransportTrackerGroupProfileParcelResource() resource.Resource { + return &TransportTrackerGroupProfileParcelResource{} +} + +type TransportTrackerGroupProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *TransportTrackerGroupProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_tracker_group_profile_parcel" +} + +func (r *TransportTrackerGroupProfileParcelResource) 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 Transport Tracker Group profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "tracker_elements": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker parcel ref list").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "tracker_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`), ""), + }, + }, + }, + }, + }, + "tracker_boolean": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("tracker ref list combine boolean and or").AddStringEnumDescription("and", "or").AddDefaultValueDescription("or").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("and", "or"), + }, + }, + "tracker_boolean_variable": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, + Optional: true, + }, + }, + } +} + +func (r *TransportTrackerGroupProfileParcelResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*SdwanProviderData).Client + r.updateMutex = req.ProviderData.(*SdwanProviderData).UpdateMutex +} + +// End of section. //template:end model + +// Section below is generated&owned by "gen/generator.go". //template:begin create +func (r *TransportTrackerGroupProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan TransportTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + + // Create object + body := plan.toBody(ctx) + + 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("parcelId").String()) + plan.Version = types.Int64Value(0) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end create + +// Section below is generated&owned by "gen/generator.go". //template:begin read +func (r *TransportTrackerGroupProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state TransportTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) + if res.Get("error.message").String() == "Invalid feature Id" { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + // If every attribute is set to null we are dealing with an import operation and therefore reading all attributes + if state.isNull(ctx, res) { + state.fromBody(ctx, res) + } else { + state.updateFromBody(ctx, res) + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Name.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end read + +// Section below is generated&owned by "gen/generator.go". //template:begin update +func (r *TransportTrackerGroupProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state TransportTrackerGroup + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) + + body := plan.toBody(ctx) + 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 + } + + plan.Version = types.Int64Value(state.Version.ValueInt64() + 1) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Name.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +// End of section. //template:end update + +// Section below is generated&owned by "gen/generator.go". //template:begin delete +func (r *TransportTrackerGroupProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state TransportTrackerGroup + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + 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 && res.Get("error.message").String() != "Invalid Template Id" { + 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 *TransportTrackerGroupProfileParcelResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +// End of section. //template:end import diff --git a/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel_test.go b/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel_test.go new file mode 100644 index 00000000..696907ae --- /dev/null +++ b/internal/provider/resource_sdwan_transport_tracker_group_profile_parcel_test.go @@ -0,0 +1,112 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin testAcc +func TestAccSdwanTransportTrackerGroupProfileParcel(t *testing.T) { + if os.Getenv("SDWAN_2012") == "" { + t.Skip("skipping test, set environment variable SDWAN_2012") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_tracker_group_profile_parcel.test", "tracker_boolean", "or")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + + { + Config: testAccSdwanTransportTrackerGroupPrerequisitesProfileParcelConfig + testAccSdwanTransportTrackerGroupProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanTransportTrackerGroupPrerequisitesProfileParcelConfig = ` +resource "sdwan_transport_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" +} + +resource "sdwan_transport_tracker_profile_parcel" "test-1" { + name = "TF_TEST_1" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} + +resource "sdwan_transport_tracker_profile_parcel" "test-2" { + name = "TF_TEST_2" + description = "Terraform Test" + feature_profile_id = sdwan_transport_feature_profile.test.id + tracker_name = "TRACKER_1" + endpoint_api_url = "google.com" + endpoint_dns_name = "google.com" + endpoint_ip = "1.2.3.4" + interval = 30 + multiplier = 3 + threshold = 300 + endpoint_tracker_type = "interface" + tracker_type = "endpoint" +} +` + +// End of section. //template:end testPrerequisites + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanTransportTrackerGroupProfileParcelConfig_all() string { + config := `resource "sdwan_transport_tracker_group_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_transport_feature_profile.test.id` + "\n" + config += ` tracker_elements = [{` + "\n" + config += ` tracker_id = sdwan_transport_tracker_profile_parcel.test-1.id` + "\n" + config += ` }, {` + "\n" + config += ` tracker_id = sdwan_transport_tracker_profile_parcel.test-2.id` + "\n" + config += ` }]` + "\n" + config += ` tracker_boolean = "or"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/internal/provider/resource_sdwan_transport_tracker_profile_parcel.go b/internal/provider/resource_sdwan_transport_tracker_profile_parcel.go new file mode 100644 index 00000000..ed81a3f0 --- /dev/null +++ b/internal/provider/resource_sdwan_transport_tracker_profile_parcel.go @@ -0,0 +1,341 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +package provider + +// Section below is generated&owned by "gen/generator.go". //template:begin imports +import ( + "context" + "fmt" + "net/url" + "regexp" + "sync" + + "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "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 provider defined types fully satisfy framework interfaces +var _ resource.Resource = &TransportTrackerProfileParcelResource{} +var _ resource.ResourceWithImportState = &TransportTrackerProfileParcelResource{} + +func NewTransportTrackerProfileParcelResource() resource.Resource { + return &TransportTrackerProfileParcelResource{} +} + +type TransportTrackerProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *TransportTrackerProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_transport_tracker_profile_parcel" +} + +func (r *TransportTrackerProfileParcelResource) 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 Transport Tracker profile parcel.").AddMinimumVersionDescription("20.12.0").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the profile parcel", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "version": schema.Int64Attribute{ + MarkdownDescription: "The version of the profile parcel", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The name of the profile parcel", + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "The description of the profile parcel", + Optional: true, + }, + "feature_profile_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Feature Profile ID").String, + Required: true, + }, + "tracker_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Tracker Name").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 128), + stringvalidator.RegexMatches(regexp.MustCompile(`^[^