diff --git a/CHANGELOG.md b/CHANGELOG.md index 261830b2..a6df1125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add `sdwan_application_priority_feature_profile` resource and data source - Add `sdwan_application_priority_qos_policy_profile_parcel` resource and data source - Add `sdwan_transport_wan_vpn_interface_ethernet_profile_parcel` resource and data source +- Add `sdwan_application_priority_traffic_policy_profile_parcel` resource and data source ## 0.3.9 diff --git a/docs/data-sources/application_priority_traffic_policy_profile_parcel.md b/docs/data-sources/application_priority_traffic_policy_profile_parcel.md new file mode 100644 index 00000000..574c02d8 --- /dev/null +++ b/docs/data-sources/application_priority_traffic_policy_profile_parcel.md @@ -0,0 +1,154 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_application_priority_traffic_policy_profile_parcel Data Source - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This data source can read the Application Priority Traffic Policy profile parcel. +--- + +# sdwan_application_priority_traffic_policy_profile_parcel (Data Source) + +This data source can read the Application Priority Traffic Policy profile parcel. + +## Example Usage + +```terraform +data "sdwan_application_priority_traffic_policy_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 + +- `default_action` (String) +- `description` (String) The description of the profile parcel +- `name` (String) The name of the profile parcel +- `sequences` (Attributes List) Traffic policy sequence list (see [below for nested schema](#nestedatt--sequences)) +- `simple_flow` (Boolean) +- `target_direction` (String) +- `version` (Number) The version of the profile parcel +- `vpn` (Set of String) + + +### Nested Schema for `sequences` + +Read-Only: + +- `actions` (Attributes List) (see [below for nested schema](#nestedatt--sequences--actions)) +- `base_action` (String) Base Action +- `matches` (Attributes List) (see [below for nested schema](#nestedatt--sequences--matches)) +- `name` (String) Sequence Name +- `protocol` (String) Sequence IP Type +- `sequence_id` (Number) Sequence Id + + +### Nested Schema for `sequences.actions` + +Read-Only: + +- `backup_sla_preferred_color` (Set of String) Backup SLA perferred color +- `cflowd` (Boolean) +- `counter` (String) +- `dre_optimization` (Boolean) +- `fallback_to_routing` (Boolean) +- `log` (Boolean) +- `loss_correct_fec_threshold` (Number) +- `loss_correction_type` (String) +- `nat_bypass` (Boolean) +- `nat_dia_interface` (Set of String) +- `nat_dia_pool` (Set of Number) +- `nat_fallback` (Boolean) +- `nat_pool` (Number) +- `nat_vpn` (Boolean) +- `redirect_dns_field` (String) +- `redirect_dns_value` (String) +- `secure_internet_gateway` (Boolean) +- `secure_service_edge` (String) +- `secure_service_edge_instance` (String) +- `service_node_group` (String) +- `sets` (Attributes List) (see [below for nested schema](#nestedatt--sequences--actions--sets)) +- `sla_class` (Attributes List) slaClass (see [below for nested schema](#nestedatt--sequences--actions--sla_class)) +- `tcp_optimization` (Boolean) + + +### Nested Schema for `sequences.actions.sets` + +Read-Only: + +- `dscp` (Number) +- `forwarding_class_id` (String) +- `local_tloc_list_color` (Set of String) +- `local_tloc_list_encapsulation` (String) +- `local_tloc_restrict` (String) +- `next_hop` (String) +- `next_hop_ipv6` (String) +- `policer_id` (String) +- `preferred_color_group_id` (String) +- `preferred_remote_color_id` (Set of String) +- `preferred_remote_color_restrict` (String) +- `service_chain_encapsulation` (String) +- `service_chain_fallback_to_routing` (Boolean) +- `service_chain_id` (String) +- `service_chain_local` (Boolean) +- `service_chain_tloc` (Set of String) +- `service_chain_tloc_list_id` (String) +- `service_chain_type` (String) +- `service_chain_vpn` (Number) +- `service_color` (Set of String) +- `service_encapsulation` (String) +- `service_tloc_ip` (String) +- `service_tloc_list_id` (String) +- `service_type` (String) +- `service_vpn` (String) +- `tloc_color` (Set of String) +- `tloc_encapsulation` (String) +- `tloc_ip` (String) +- `tloc_list_id` (String) +- `vpn` (String) + + + +### Nested Schema for `sequences.actions.sla_class` + +Read-Only: + +- `fallback_to_best_path` (Boolean) +- `preferred_color` (Set of String) +- `preferred_color_group_id` (String) +- `preferred_remote_color` (Set of String) +- `remote_color_restrict` (Boolean) +- `sla_class_list_id` (String) +- `strict_drop` (Boolean) + + + + +### Nested Schema for `sequences.matches` + +Read-Only: + +- `application_list_id` (String) +- `destination_data_ipv6_prefix_list_id` (String) +- `destination_data_prefix_list_id` (String) +- `destination_port` (Set of String) Destination Port (0-65535) range or individual number separated by space +- `destination_region` (String) Destination Region +- `dns` (String) Dns +- `dns_application_list_id` (String) +- `dscp` (Number) DSCP number +- `packet_length` (String) Packet Length +- `protocol` (Set of String) protocol (0-255) range or individual number separated by space +- `source_data_ipv6_prefix_list_id` (String) +- `source_data_prefix_list_id` (String) +- `source_port` (Set of String) Source Port (0-65535) range or individual number separated by space +- `tcp` (String) TCP States +- `traffic_class` (String) Traffic Class +- `traffic_to` (String) Traffic to diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 9158f431..a44de771 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -18,6 +18,7 @@ description: |- - Add `sdwan_application_priority_feature_profile` resource and data source - Add `sdwan_application_priority_qos_policy_profile_parcel` resource and data source - Add `sdwan_transport_wan_vpn_interface_ethernet_profile_parcel` resource and data source +- Add `sdwan_application_priority_traffic_policy_profile_parcel` resource and data source ## 0.3.9 diff --git a/docs/resources/application_priority_traffic_policy_profile_parcel.md b/docs/resources/application_priority_traffic_policy_profile_parcel.md new file mode 100644 index 00000000..7d67d178 --- /dev/null +++ b/docs/resources/application_priority_traffic_policy_profile_parcel.md @@ -0,0 +1,255 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sdwan_application_priority_traffic_policy_profile_parcel Resource - terraform-provider-sdwan" +subcategory: "Profile Parcels" +description: |- + This resource can manage a Application Priority Traffic Policy profile parcel. + Minimum SD-WAN Manager version: 20.12.0 +--- + +# sdwan_application_priority_traffic_policy_profile_parcel (Resource) + +This resource can manage a Application Priority Traffic Policy profile parcel. + - Minimum SD-WAN Manager version: `20.12.0` + +## Example Usage + +```terraform +resource "sdwan_application_priority_traffic_policy_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + default_action = "accept" + simple_flow = false + vpn = ["1"] + target_direction = "all" + sequences = [ + { + sequence_id = 1 + name = "RULE_1" + base_action = "accept" + protocol = "ipv4" + matches = [ + { + dscp = 1 + packet_length = "123" + protocol = ["2"] + tcp = "gre" + traffic_to = "core" + } + ] + actions = [ + { + counter = "COUNTER_1" + log = false + sla_class = [ + { + preferred_color = ["default"] + strict_drop = true + fallback_to_best_path = false + } + ] + backup_sla_preferred_color = ["default"] + sets = [ + { + dscp = 1 + local_tloc_list_color = ["default"] + local_tloc_restrict = "false" + local_tloc_list_encapsulation = "gre" + tloc_ip = "1.2.3.4" + tloc_color = ["default"] + tloc_encapsulation = "gre" + service_type = "FW" + service_color = ["default"] + service_encapsulation = "ipsec" + service_tloc_ip = "1.2.3.4" + service_vpn = "1" + service_chain_type = "SC1" + service_chain_vpn = 1 + service_chain_local = false + service_chain_fallback_to_routing = false + service_chain_tloc = ["default"] + service_chain_encapsulation = "ipsec" + service_chain_id = "1.2.3.4" + next_hop = "1.2.3.4" + next_hop_ipv6 = "2001:0:0:1::/64" + vpn = "1" + } + ] + redirect_dns_field = "redirectDns" + redirect_dns_value = "umbrella" + tcp_optimization = true + dre_optimization = true + service_node_group = "SNG-APPQOE1" + loss_correction_type = "fecAdaptive" + loss_correct_fec_threshold = 1 + cflowd = true + nat_pool = 2 + nat_vpn = 0 + nat_fallback = false + nat_bypass = false + nat_dia_pool = [1] + nat_dia_interface = ["ethernet"] + secure_internet_gateway = true + fallback_to_routing = true + secure_service_edge_instance = "zScaler" + } + ] + } + ] +} +``` + + +## Schema + +### Required + +- `default_action` (String) - Choices: `drop`, `accept` +- `feature_profile_id` (String) Feature Profile ID +- `name` (String) The name of the profile parcel +- `simple_flow` (Boolean) +- `target_direction` (String) - Choices: `service`, `tunnel`, `all` +- `vpn` (Set of String) + +### Optional + +- `description` (String) The description of the profile parcel +- `sequences` (Attributes List) Traffic policy sequence list (see [below for nested schema](#nestedatt--sequences)) + +### Read-Only + +- `id` (String) The id of the profile parcel +- `version` (Number) The version of the profile parcel + + +### Nested Schema for `sequences` + +Optional: + +- `actions` (Attributes List) (see [below for nested schema](#nestedatt--sequences--actions)) +- `base_action` (String) Base Action + - Choices: `drop`, `accept` +- `matches` (Attributes List) (see [below for nested schema](#nestedatt--sequences--matches)) +- `name` (String) Sequence Name +- `protocol` (String) Sequence IP Type + - Choices: `ipv4`, `ipv6`, `all` +- `sequence_id` (Number) Sequence Id + - Range: `1`-`65536` + + +### Nested Schema for `sequences.actions` + +Optional: + +- `backup_sla_preferred_color` (Set of String) Backup SLA perferred color +- `cflowd` (Boolean) +- `counter` (String) +- `dre_optimization` (Boolean) +- `fallback_to_routing` (Boolean) +- `log` (Boolean) +- `loss_correct_fec_threshold` (Number) - Range: `1`-`5` +- `loss_correction_type` (String) - Choices: `fecAdaptive`, `fecAlways`, `packetDuplication` +- `nat_bypass` (Boolean) +- `nat_dia_interface` (Set of String) +- `nat_dia_pool` (Set of Number) +- `nat_fallback` (Boolean) +- `nat_pool` (Number) - Range: `1`-`31` +- `nat_vpn` (Boolean) +- `redirect_dns_field` (String) - Choices: `ipAddress`, `redirectDns` +- `redirect_dns_value` (String) +- `secure_internet_gateway` (Boolean) +- `secure_service_edge` (String) +- `secure_service_edge_instance` (String) - Choices: `Cisco-Secure-Access`, `zScaler` +- `service_node_group` (String) +- `sets` (Attributes List) (see [below for nested schema](#nestedatt--sequences--actions--sets)) +- `sla_class` (Attributes List) slaClass (see [below for nested schema](#nestedatt--sequences--actions--sla_class)) +- `tcp_optimization` (Boolean) + + +### Nested Schema for `sequences.actions.sets` + +Optional: + +- `dscp` (Number) - Range: `0`-`63` +- `forwarding_class_id` (String) +- `local_tloc_list_color` (Set of String) +- `local_tloc_list_encapsulation` (String) - Choices: `ipsec`, `gre` +- `local_tloc_restrict` (String) +- `next_hop` (String) +- `next_hop_ipv6` (String) +- `policer_id` (String) +- `preferred_color_group_id` (String) +- `preferred_remote_color_id` (Set of String) +- `preferred_remote_color_restrict` (String) +- `service_chain_encapsulation` (String) - Choices: `ipsec`, `gre` +- `service_chain_fallback_to_routing` (Boolean) +- `service_chain_id` (String) +- `service_chain_local` (Boolean) +- `service_chain_tloc` (Set of String) +- `service_chain_tloc_list_id` (String) +- `service_chain_type` (String) - Choices: `SC1`, `SC2`, `SC4`, `SC5`, `SC6`, `SC7`, `SC8`, `SC9`, `SC10`, `SC11`, `SC12`, `SC13`, `SC14`, `SC15`, `SC16` +- `service_chain_vpn` (Number) - Range: `0`-`65530` +- `service_color` (Set of String) +- `service_encapsulation` (String) - Choices: `ipsec`, `gre` +- `service_tloc_ip` (String) +- `service_tloc_list_id` (String) +- `service_type` (String) - Choices: `FW`, `IDS`, `IDP`, `netsvc1`, `netsvc2`, `netsvc3`, `netsvc4`, `appqoe` +- `service_vpn` (String) +- `tloc_color` (Set of String) +- `tloc_encapsulation` (String) - Choices: `ipsec`, `gre` +- `tloc_ip` (String) +- `tloc_list_id` (String) +- `vpn` (String) + + + +### Nested Schema for `sequences.actions.sla_class` + +Optional: + +- `fallback_to_best_path` (Boolean) +- `preferred_color` (Set of String) +- `preferred_color_group_id` (String) +- `preferred_remote_color` (Set of String) +- `remote_color_restrict` (Boolean) +- `sla_class_list_id` (String) +- `strict_drop` (Boolean) + + + + +### Nested Schema for `sequences.matches` + +Optional: + +- `application_list_id` (String) +- `destination_data_ipv6_prefix_list_id` (String) +- `destination_data_prefix_list_id` (String) +- `destination_port` (Set of String) Destination Port (0-65535) range or individual number separated by space +- `destination_region` (String) Destination Region + - Choices: `primary-region`, `secondary-region`, `other-region` +- `dns` (String) Dns + - Choices: `request`, `response` +- `dns_application_list_id` (String) +- `dscp` (Number) DSCP number + - Range: `0`-`63` +- `packet_length` (String) Packet Length +- `protocol` (Set of String) protocol (0-255) range or individual number separated by space +- `source_data_ipv6_prefix_list_id` (String) +- `source_data_prefix_list_id` (String) +- `source_port` (Set of String) Source Port (0-65535) range or individual number separated by space +- `tcp` (String) TCP States + - Choices: `syn` +- `traffic_class` (String) Traffic Class + - Choices: `gold-voip-telephony`, `gold-broadcast-video`, `gold-real-time-interactive`, `gold-multimedia-conferencing`, `gold-multimedia-streaming`, `gold-network-control`, `gold-signaling`, `gold-ops-admin-mgmt`, `gold-transactional-data`, `gold-bulk-data`, `silver`, `bronze` +- `traffic_to` (String) Traffic to + - Choices: `core`, `service`, `access` + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_application_priority_traffic_policy_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/examples/data-sources/sdwan_application_priority_traffic_policy_profile_parcel/data-source.tf b/examples/data-sources/sdwan_application_priority_traffic_policy_profile_parcel/data-source.tf new file mode 100644 index 00000000..20ee98dc --- /dev/null +++ b/examples/data-sources/sdwan_application_priority_traffic_policy_profile_parcel/data-source.tf @@ -0,0 +1,4 @@ +data "sdwan_application_priority_traffic_policy_profile_parcel" "example" { + id = "f6b2c44c-693c-4763-b010-895aa3d236bd" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" +} diff --git a/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/import.sh b/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/import.sh new file mode 100644 index 00000000..7019a886 --- /dev/null +++ b/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/import.sh @@ -0,0 +1 @@ +terraform import sdwan_application_priority_traffic_policy_profile_parcel.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/resource.tf b/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/resource.tf new file mode 100644 index 00000000..de8d8a56 --- /dev/null +++ b/examples/resources/sdwan_application_priority_traffic_policy_profile_parcel/resource.tf @@ -0,0 +1,83 @@ +resource "sdwan_application_priority_traffic_policy_profile_parcel" "example" { + name = "Example" + description = "My Example" + feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" + default_action = "accept" + simple_flow = false + vpn = ["1"] + target_direction = "all" + sequences = [ + { + sequence_id = 1 + name = "RULE_1" + base_action = "accept" + protocol = "ipv4" + matches = [ + { + dscp = 1 + packet_length = "123" + protocol = ["2"] + tcp = "gre" + traffic_to = "core" + } + ] + actions = [ + { + counter = "COUNTER_1" + log = false + sla_class = [ + { + preferred_color = ["default"] + strict_drop = true + fallback_to_best_path = false + } + ] + backup_sla_preferred_color = ["default"] + sets = [ + { + dscp = 1 + local_tloc_list_color = ["default"] + local_tloc_restrict = "false" + local_tloc_list_encapsulation = "gre" + tloc_ip = "1.2.3.4" + tloc_color = ["default"] + tloc_encapsulation = "gre" + service_type = "FW" + service_color = ["default"] + service_encapsulation = "ipsec" + service_tloc_ip = "1.2.3.4" + service_vpn = "1" + service_chain_type = "SC1" + service_chain_vpn = 1 + service_chain_local = false + service_chain_fallback_to_routing = false + service_chain_tloc = ["default"] + service_chain_encapsulation = "ipsec" + service_chain_id = "1.2.3.4" + next_hop = "1.2.3.4" + next_hop_ipv6 = "2001:0:0:1::/64" + vpn = "1" + } + ] + redirect_dns_field = "redirectDns" + redirect_dns_value = "umbrella" + tcp_optimization = true + dre_optimization = true + service_node_group = "SNG-APPQOE1" + loss_correction_type = "fecAdaptive" + loss_correct_fec_threshold = 1 + cflowd = true + nat_pool = 2 + nat_vpn = 0 + nat_fallback = false + nat_bypass = false + nat_dia_pool = [1] + nat_dia_interface = ["ethernet"] + secure_internet_gateway = true + fallback_to_routing = true + secure_service_edge_instance = "zScaler" + } + ] + } + ] +} diff --git a/gen/definitions/profile_parcels/application_priority_traffic_policy.yaml b/gen/definitions/profile_parcels/application_priority_traffic_policy.yaml new file mode 100644 index 00000000..ea5ed6f6 --- /dev/null +++ b/gen/definitions/profile_parcels/application_priority_traffic_policy.yaml @@ -0,0 +1,378 @@ +--- +name: Application Priority Traffic Policy +rest_endpoint: /v1/feature-profile/sdwan/application-priority/%v/traffic-policy +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_application_priority_feature_profile.test.id + - model_name: dataDefaultAction + tf_name: default_action + example: accept + + - model_name: simpleFlow + example: false + # - model_name: hasCorViaSig + # tf_name: + # example: false + + - model_name: vpn + data_path: [target] + example: 1 + - model_name: direction + tf_name: target_direction + data_path: [target] + example: all + - model_name: sequences + attributes: + - model_name: sequenceId + example: 1 + - model_name: sequenceName + tf_name: name + example: RULE_1 + - model_name: baseAction + example: accept + - model_name: sequenceIpType + tf_name: protocol + example: ipv4 + - model_name: entries + tf_name: matches + data_path: [match] + attributes: + - model_name: refId + tf_name: application_list_id + data_path: [appList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: refId + tf_name: dns_application_list_id + data_path: [dnsAppList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: dns + exclude_test: true + example: response + - model_name: dscp + example: 1 + - model_name: packetLength + example: 123 + - model_name: protocol + example: 2 + - model_name: refId + tf_name: source_data_prefix_list_id + data_path: [sourceDataPrefixList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: refId + tf_name: source_data_ipv6_prefix_list_id + data_path: [sourceDataIpv6PrefixList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: sourcePort + exclude_test: true + example: 1234 + + - model_name: refId + tf_name: destination_data_prefix_list_id + data_path: [destinationDataPrefixList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: refId + tf_name: destination_data_ipv6_prefix_list_id + data_path: [destinationDataIpv6PrefixList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: destinationPort + exclude_test: true + example: 2345 + - model_name: destinationRegion + exclude_test: true + example: primary-region + + # - model_name: refId + # tf_name: saas_application_list_id + # data_path: [saasAppList] + # exclude_test: true + # example: exchange + + - model_name: tcp + example: gre + - model_name: trafficTo + example: core + - model_name: trafficClass + exclude_test: true + example: silver + + # - model_name: icmpMessage + # tf_name: + # example: administratively-prohibited + # - model_name: icmp6Message + # tf_name: + # example: beyond-scope + + # - model_name: serviceArea + # tf_name: + # example: common + # - model_name: trafficCategory + # tf_name: + # example: optimize-allow + + # - model_name: sourceIp + # tf_name: + # data_path: + # example: + # - model_name: sourceIpv6 + # tf_name: + # data_path: + # example: + + # - model_name: destinationIp + # tf_name: + # data_path: + # example: + # - model_name: destinationIpv6 + # tf_name: + # data_path: + # example: + + - model_name: actions + attributes: + - model_name: count + tf_name: counter + example: COUNTER_1 + - model_name: log + example: false + - model_name: slaClass + attributes: + - model_name: refId + tf_name: sla_class_list_id + data_path: [slaName] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: preferredColor + example: default + - model_name: refId + tf_name: preferred_color_group_id + data_path: [preferredColorGroup] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: strict + tf_name: strict_drop + example: true + - model_name: fallbackToBestPath + example: false + - model_name: preferredRemoteColor + exclude_test: true + example: 3g + - model_name: remoteColorRestrict + exclude_test: true + example: true + - model_name: backupSlaPreferredColor + example: default + - model_name: set + tf_name: sets + attributes: + - model_name: dscp + example: 1 + - model_name: refId + tf_name: policer_id + data_path: [policer] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: refId + tf_name: preferred_color_group_id + data_path: [preferredColorGroup] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: refId + tf_name: forwarding_class_id + data_path: [forwardingClass] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: color + tf_name: local_tloc_list_color + data_path: [localTlocList] + example: default + - model_name: restrict + tf_name: local_tloc_restrict + data_path: [localTlocList] + example: false + - model_name: encap + tf_name: local_tloc_list_encapsulation + data_path: [localTlocList] + example: gre + - model_name: color + tf_name: preferred_remote_color_id + data_path: [preferredRemoteColor] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: remoteColorRestrict + tf_name: preferred_remote_color_restrict + data_path: [preferredRemoteColor] + exclude_test: true + example: false + - model_name: ip + tf_name: tloc_ip + data_path: [tloc] + example: 1.2.3.4 + - model_name: color + tf_name: tloc_color + data_path: [tloc] + example: default + - model_name: encap + tf_name: tloc_encapsulation + data_path: [tloc] + example: gre + - model_name: refId + tf_name: tloc_list_id + data_path: [tlocList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: type + tf_name: service_type + data_path: [service] + example: FW + - model_name: color + tf_name: service_color + data_path: [service, tloc] + example: default + - model_name: encap + tf_name: service_encapsulation + data_path: [service, tloc] + example: ipsec + - model_name: ip + tf_name: service_tloc_ip + data_path: [service, tloc] + example: 1.2.3.4 + - model_name: vpn + tf_name: service_vpn + data_path: [service] + example: 1 + - model_name: refId + tf_name: service_tloc_list_id + data_path: [service, tlocList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + # ==== 20.14 ==== + - model_name: type + tf_name: service_chain_type + data_path: [serviceChain] + example: SC1 + - model_name: vpn + tf_name: service_chain_vpn + data_path: [serviceChain] + example: 1 + - model_name: local + tf_name: service_chain_local + data_path: [serviceChain] + example: false + - model_name: restrict + tf_name: service_chain_fallback_to_routing + data_path: [serviceChain] + example: false + - model_name: color + tf_name: service_chain_tloc + data_path: [serviceChain, tloc] + example: default + - model_name: encap + tf_name: service_chain_encapsulation + data_path: [serviceChain, tloc] + example: ipsec + - model_name: ip + tf_name: service_chain_id + data_path: [serviceChain, tloc] + example: 1.2.3.4 + - model_name: refId + tf_name: service_chain_tloc_list_id + data_path: [serviceChain, tlocList] + exclude_test: true + example: a509839f-33aa-492a-ab8e-6a6fe70d7d79 + - model_name: nextHop + example: 1.2.3.4 + - model_name: nextHopIpv6 + example: 2001:0:0:1::/64 + - model_name: vpn + example: 1 + - model_name: field + tf_name: redirect_dns_field + data_path: [redirectDns] + example: redirectDns + - model_name: value + tf_name: redirect_dns_value + data_path: [redirectDns] + example: umbrella + # ==== 20.14 ==== + - model_name: tcpOptimization + data_path: [appqoeOptimization] + example: true + - model_name: dreOptimization + data_path: [appqoeOptimization] + example: true + - model_name: serviceNodeGroup + data_path: [appqoeOptimization] + example: SNG-APPQOE1 + # ==== 20.14 ==== + - model_name: lossCorrectionType + data_path: [lossCorrection] + example: fecAdaptive + - model_name: lossCorrectFec + tf_name: loss_correct_fec_threshold + data_path: [lossCorrection] + example: 1 + + # - model_name: cloudSaas + # # tf_name: + # # example: false + # - model_name: cloudProbe + # # tf_name: + # # example: false + + - model_name: cflowd + example: true + - model_name: natPool + example: 2 + - model_name: useVpn + tf_name: nat_vpn + data_path: [nat] + example: 0 + - model_name: fallback + tf_name: nat_fallback + data_path: [nat] + example: false + # ==== 20.14 ==== + - model_name: bypass + tf_name: nat_bypass + data_path: [nat] + example: false + - model_name: diaPool + tf_name: nat_dia_pool + data_path: [nat] + example: 1 + - model_name: diaInterface + tf_name: nat_dia_interface + data_path: [nat] + example: ethernet + - model_name: sig + tf_name: secure_internet_gateway + example: true + - model_name: fallbackToRouting + example: true + # ==== 20.14 ==== + - model_name: secureServiceEdge + data_path: [sse] + exclude_test: true + example: true + - model_name: secureServiceEdgeInstance + data_path: [sse] + example: zScaler + +test_prerequisites: | + resource "sdwan_application_priority_feature_profile" "test" { + name = "TF_TEST" + description = "Terraform test" + } \ No newline at end of file diff --git a/gen/generator.go b/gen/generator.go index a196320b..8fe0a7fb 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -752,7 +752,7 @@ func parseProfileParcelAttribute(attr *YamlConfigAttribute, model gjson.Result, if value := t.Get("properties.value.maximum"); value.Exists() { attr.MaxInt = value.Int() } - } else if t.Get("properties.value.type").String() == "array" && t.Get("properties.value.items.type").String() == "string" { + } else if t.Get("properties.value.type").String() == "array" && t.Get("properties.value.items.type").String() == "string" || t.Get("properties.value.items.oneOf.0.type").String() == "string" { attr.Type = "Set" attr.ElementType = "String" // if value := t.Get("properties.value.items.minItems"); value.Exists() { diff --git a/gen/models/profile_parcels/application_priority_traffic_policy.json b/gen/models/profile_parcels/application_priority_traffic_policy.json new file mode 100644 index 00000000..f0a1c6d2 --- /dev/null +++ b/gen/models/profile_parcels/application_priority_traffic_policy.json @@ -0,0 +1,3093 @@ +{ + "request": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "https://cisco.com/schema/profileparcel/sdwan/application-priority/traffic-policy/post/request_schema.json", + "title": "traffic policy Parcel Schema", + "description": "traffic policy profile parcel schema for POST request", + "type": "object", + "properties": { + "name": { + "description": "Set the parcel name", + "type": "string", + "pattern": "^[^&<>! \"]+$", + "minLength": 1, + "maxLength": 128 + }, + "description": { + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "dataDefaultAction": { + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "default": "accept", + "enum": ["drop", "accept"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "simpleFlow": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "hasCorViaSig": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "target": { + "description": "Target vpn and direction", + "type": "object", + "properties": { + "vpn": { + "description": "", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "direction": { + "description": "", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "default": "all", + "enum": ["service", "tunnel", "all"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + } + }, + "additionalProperties": false + }, + "sequences": { + "description": "Traffic policy sequence list", + "type": "array", + "uniqueItems": true, + "items": { + "type": "object", + "properties": { + "sequenceId": { + "description": "Sequence Id", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "minimum": 1, + "maximum": 65536, + "type": "integer" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "sequenceName": { + "description": "Sequence Name", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "baseAction": { + "description": "Base Action", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "default": "accept", + "enum": ["drop", "accept"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "sequenceIpType": { + "description": "Sequence IP Type", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "default": "ipv4", + "enum": ["ipv4", "ipv6", "all"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "match": { + "type": "object", + "properties": { + "entries": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "object", + "minProperties": 1, + "maxProperties": 1, + "properties": { + "appList": { + "description": "App list Reference", + "type": "object", + "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 + } + } + }, + "saasAppList": { + "description": "Saas App list Reference", + "type": "object", + "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 + } + } + }, + "serviceArea": { + "description": "M365 Service Area", + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "common", + "exchange", + "sharepoint", + "skype" + ] + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "trafficCategory": { + "description": "M365 Traffic Category", + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["optimize-allow", "optimize", "all"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "dnsAppList": { + "description": "dns App list Reference", + "type": "object", + "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 + } + } + }, + "trafficClass": { + "description": "Traffic Class", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": [ + "gold-voip-telephony", + "gold-broadcast-video", + "gold-real-time-interactive", + "gold-multimedia-conferencing", + "gold-multimedia-streaming", + "gold-network-control", + "gold-signaling", + "gold-ops-admin-mgmt", + "gold-transactional-data", + "gold-bulk-data", + "silver", + "bronze" + ], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "dscp": { + "description": "DSCP number", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "minimum": 0, + "maximum": 63, + "type": "integer" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "packetLength": { + "description": "Packet Length", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "oneOf": [ + { + "type": "string", + "pattern": "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + }, + { + "type": "string", + "pattern": "^([0-9]|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\\-([1-9]|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + } + ] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "protocol": { + "description": "protocol (0-255) range or individual number separated by space", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "pattern": "^(0|[1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "icmpMessage": { + "description": "ICMP Message", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "administratively-prohibited", + "dod-host-prohibited", + "dod-net-prohibited", + "echo", + "echo-reply", + "echo-reply-no-error", + "extended-echo", + "extended-echo-reply", + "general-parameter-problem", + "host-isolated", + "host-precedence-unreachable", + "host-redirect", + "host-tos-redirect", + "host-tos-unreachable", + "host-unknown", + "host-unreachable", + "interface-error", + "malformed-query", + "multiple-interface-match", + "net-redirect", + "net-tos-redirect", + "net-tos-unreachable", + "net-unreachable", + "network-unknown", + "no-room-for-option", + "option-missing", + "packet-too-big", + "parameter-problem", + "photuris", + "port-unreachable", + "precedence-unreachable", + "protocol-unreachable", + "reassembly-timeout", + "redirect", + "router-advertisement", + "router-solicitation", + "source-route-failed", + "table-entry-error", + "time-exceeded", + "timestamp-reply", + "timestamp-request", + "ttl-exceeded", + "unreachable" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "icmp6Message": { + "description": "ICMP6 Message", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "beyond-scope", + "cp-advertisement", + "cp-solicitation", + "destination-unreachable", + "dhaad-reply", + "dhaad-request", + "echo-reply", + "echo-request", + "header", + "hop-limit", + "ind-advertisement", + "ind-solicitation", + "mld-query", + "mld-reduction", + "mld-report", + "mldv2-report", + "mpd-advertisement", + "mpd-solicitation", + "mr-advertisement", + "mr-solicitation", + "mr-termination", + "nd-na", + "nd-ns", + "next-header-type", + "ni-query", + "ni-query-name", + "ni-query-v4-address", + "ni-query-v6-address", + "ni-response", + "ni-response-qtype-unknown", + "ni-response-refuse", + "ni-response-success", + "no-admin", + "no-route", + "packet-too-big", + "parameter-option", + "parameter-problem", + "port-unreachable", + "reassembly-timeout", + "redirect", + "reject-route", + "renum-command", + "renum-result", + "renum-seq-number", + "router-advertisement", + "router-renumbering", + "router-solicitation", + "rpl-control", + "source-policy", + "source-route-header", + "time-exceeded", + "unreachable" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "sourceDataPrefixList": { + "description": "Source Data Prefix Parcel UUID", + "type": "object", + "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 + } + } + }, + "sourceDataIpv6PrefixList": { + "description": "Source Data Prefix Parcel UUID", + "type": "object", + "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 + } + } + }, + "sourceIp": { + "description": "Source Data IP Prefix", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "sourceIpv6": { + "description": "Source Data IP Prefix", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv6" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "sourcePort": { + "description": "Source Port (0-65535) range or individual number separated by space", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "oneOf": [ + { + "type": "string", + "pattern": "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + }, + { + "type": "string", + "pattern": "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\\-(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + } + ] + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "destinationDataPrefixList": { + "description": "Destination Data Prefix Parcel UUID", + "type": "object", + "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 + } + } + }, + "destinationDataIpv6PrefixList": { + "description": "Destination Data Prefix Parcel UUID", + "type": "object", + "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 + } + } + }, + "destinationIp": { + "description": "Destination Data IP Prefix", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "destinationIpv6": { + "description": "Destination Data IP Prefix", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv6" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "destinationPort": { + "description": "Destination Port (0-65535) range or individual number separated by space", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "items": { + "oneOf": [ + { + "type": "string", + "pattern": "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + }, + { + "type": "string", + "pattern": "^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\\-(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" + } + ] + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "tcp": { + "description": "TCP States", + "type": "object", + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": ["syn"], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "destinationRegion": { + "description": "Destination Region", + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": [ + "primary-region", + "secondary-region", + "other-region" + ] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "trafficTo": { + "description": "Traffic to", + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["core", "service", "access"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "dns": { + "description": "Dns", + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["request", "response"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "allOf": [ + { + "if": { + "contains": { + "required": ["trafficClass"] + } + }, + "then": { + "not": { + "contains": { + "required": ["appList"] + } + } + } + }, + { + "if": { + "contains": { + "required": ["sourceIp"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["sourceDataIpv6PrefixList"] + }, + { + "required": ["sourceDataPrefixList"] + }, + { + "required": ["sourceDataIpv6"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["sourceIpv6"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["sourceDataIpv6PrefixList"] + }, + { + "required": ["sourceDataPrefixList"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["sourceDataIpv6PrefixList"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["sourceDataPrefixList"] + }, + { + "required": ["dnsAppList"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["destinationIp"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": [ + "destinationDataIpv6PrefixList" + ] + }, + { + "required": ["destinationDataPrefixList"] + }, + { + "required": ["destinationDataIpv6"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["destinationIpv6"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": [ + "destinationDataIpv6PrefixList" + ] + }, + { + "required": ["destinationDataPrefixList"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["destinationDataIpv6PrefixList"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["destinationDataPrefixList"] + }, + { + "required": ["dnsAppList"] + } + ] + } + } + } + } + ] + } + }, + "required": ["entries"], + "additionalProperties": false + }, + "actions": { + "type": "array", + "items": { + "type": "object", + "minProperties": 1, + "maxProperties": 1, + "properties": { + "slaClass": { + "type": "array", + "description": "slaClass", + "items": { + "type": "object", + "properties": { + "slaName": { + "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 + } + } + }, + "preferredColor": { + "not": { + "required": ["preferredColorGroup"] + }, + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "preferredColorGroup": { + "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 + } + } + }, + "strict": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "fallbackToBestPath": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "preferredRemoteColor": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "remoteColorRestrict": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + } + }, + "additionalProperties": false + }, + "allOf": [ + { + "if": { + "contains": { + "required": ["preferredColorGroup"] + } + }, + "then": { + "not": { + "contains": { + "required": ["preferredColor"] + } + } + } + }, + { + "if": { + "contains": { + "required": ["fallbackToBestPath"] + } + }, + "then": { + "not": { + "contains": { + "required": ["strict"] + } + } + } + } + ] + }, + "backupSlaPreferredColor": { + "type": "object", + "description": "Backup SLA perferred color", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "set": { + "type": "array", + "items": { + "type": "object", + "properties": { + "dscp": { + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "minimum": 0, + "maximum": 63, + "type": "integer" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "policer": { + "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 + } + } + }, + "preferredColorGroup": { + "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 + } + } + }, + "forwardingClass": { + "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 + } + } + }, + "localTlocList": { + "properties": { + "color": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "restrict": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "encap": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["ipsec", "gre"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["color"], + "additionalProperties": false + }, + "preferredRemoteColor": { + "properties": { + "color": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "remoteColorRestrict": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["color"], + "additionalProperties": false + }, + "tloc": { + "properties": { + "color": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "encap": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["ipsec", "gre"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "ip": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["color", "encap", "ip"], + "additionalProperties": false + }, + "tlocList": { + "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 + } + } + }, + "service": { + "oneOf": [ + { + "properties": { + "tloc": { + "properties": { + "color": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "encap": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["ipsec", "gre"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "ip": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["color", "encap", "ip"], + "additionalProperties": false + }, + "vpn": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[./\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "type": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": [ + "FW", + "IDS", + "IDP", + "netsvc1", + "netsvc2", + "netsvc3", + "netsvc4", + "appqoe" + ], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["vpn", "tloc", "type"], + "additionalProperties": false + }, + { + "properties": { + "tlocList": { + "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 + } + } + }, + "vpn": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[./\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "type": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": [ + "FW", + "IDS", + "IDP", + "netsvc1", + "netsvc2", + "netsvc3", + "netsvc4", + "appqoe" + ], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["vpn", "tlocList", "type"], + "additionalProperties": false + } + ] + }, + "serviceChain": { + "type": "object", + "properties": { + "type": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": [ + "SC1", + "SC2", + "SC4", + "SC5", + "SC6", + "SC7", + "SC8", + "SC9", + "SC10", + "SC11", + "SC12", + "SC13", + "SC14", + "SC15", + "SC16" + ], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "vpn": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "integer", + "minimum": 0, + "maximum": 65530, + "not": { + "enum": [0, 512] + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "local": { + "default": false, + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "restrict": { + "default": true, + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "tloc": { + "properties": { + "color": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "3g", + "biz-internet", + "blue", + "bronze", + "custom1", + "custom2", + "custom3", + "default", + "gold", + "green", + "lte", + "metro-ethernet", + "mpls", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", + "public-internet", + "red", + "silver" + ], + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "encap": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["ipsec", "gre"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "ip": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["color", "encap", "ip"], + "additionalProperties": false + }, + "tlocList": { + "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": ["type", "local", "restrict"], + "allOf": [ + { + "if": { + "properties": { + "local": { + "properties": { + "value": { + "const": false + } + } + } + } + }, + "then": { + "anyOf": [ + { + "required": ["tloc"] + }, + { + "required": ["tlocList"] + }, + { + "not": { + "required": ["tloc", "tlocList"] + } + } + ] + }, + "else": { + "not": { + "anyOf": [ + { + "required": ["tloc"] + }, + { + "required": ["tlocList"] + } + ] + } + } + }, + { + "if": { + "properties": { + "local": { + "properties": { + "value": { + "const": true + } + } + } + } + }, + "then": { + "anyOf": [ + { + "not": { + "required": ["vpn"] + } + }, + { + "required": ["vpn"] + } + ] + }, + "else": { + "required": ["vpn"] + } + } + ], + "additionalProperties": false + }, + "nextHop": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv4" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "nextHopIpv6": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "format": "ipv6" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "nextHopLoose": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "vpn": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "pattern": "^\\{\\{[./\\[\\]a-zA-Z0-9_-]+\\}\\}$", + "minLength": 1, + "maxLength": 64 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "allOf": [ + { + "if": { + "contains": { + "required": ["preferredColorGroup"] + } + }, + "then": { + "not": { + "contains": { + "required": ["localTlocList"] + } + } + } + }, + { + "if": { + "contains": { + "required": ["nextHopLoose"] + } + }, + "then": { + "contains": { + "oneOf": [ + { + "required": ["nextHop"] + }, + { + "required": ["nextHopIpv6"] + } + ] + } + } + }, + { + "if": { + "contains": { + "required": ["service"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["vpn"] + }, + { + "required": ["tlocList"] + }, + { + "required": ["tloc"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["serviceChain"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["service"] + }, + { + "required": ["nextHop"] + } + ] + } + } + } + } + ] + }, + "redirectDns": { + "properties": { + "field": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "enum": ["ipAddress", "redirectDns"] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "value": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "oneOf": [ + { + "type": "string", + "enum": ["umbrella", "host"] + }, + { + "type": "string", + "format": "ipv4" + } + ] + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + } + }, + "appqoeOptimization": { + "type": "object", + "properties": { + "tcpOptimization": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "dreOptimization": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "serviceNodeGroup": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "minLength": 1, + "maxLength": 12, + "pattern": "(SNG-APPQOE|(SNG-APPQOE([1-9]|[1-2][0-9]|3[0-1])))" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "minProperties": 1, + "additionalProperties": false + }, + "lossCorrection": { + "type": "object", + "properties": { + "lossCorrectionType": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": [ + "fecAdaptive", + "fecAlways", + "packetDuplication" + ], + "type": "string" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "lossCorrectFec": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "integer", + "minimum": 1, + "maximum": 5 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + }, + "required": ["lossCorrectionType"], + "anyOf": [ + { + "if": { + "properties": { + "lossCorrectionType": { + "properties": { + "value": { + "const": "fecAdaptive" + } + } + } + } + }, + "then": { + "anyOf": [ + { + "required": ["lossCorrectFec"] + }, + { + "not": { + "required": ["lossCorrectFec"] + } + } + ] + }, + "else": { + "not": { + "required": ["lossCorrectFec"] + } + } + } + ], + "additionalProperties": false + }, + "count": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string", + "minLength": 1, + "maxLength": 20 + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "log": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "cloudSaas": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "cloudProbe": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "cflowd": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "natPool": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "minimum": 1, + "maximum": 31, + "type": "integer" + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + }, + "nat": { + "type": "object", + "properties": { + "useVpn": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "fallback": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "bypass": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "diaPool": { + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "maxItems": 4, + "uniqueItems": true, + "items": { + "minimum": 1, + "maximum": 4095, + "type": "integer" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + }, + "diaInterface": { + "oneOf": [ + { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "array", + "minItems": 1, + "maxItems": 4, + "uniqueItems": true, + "items": { + "type": "string" + } + } + }, + "required": ["optionType", "value"], + "additionalProperties": false + } + ] + } + }, + "required": ["useVpn"], + "anyOf": [ + { + "if": { + "properties": { + "bypass": { + "properties": { + "value": { + "const": false + } + } + } + } + }, + "then": { + "anyOf": [ + { + "required": ["diaPool"] + }, + { + "required": ["diaInterface"] + }, + { + "not": { + "required": ["diaPool", "diaInterface"] + } + } + ] + }, + "else": { + "not": { + "anyOf": [ + { + "required": ["diaPool"] + }, + { + "required": ["diaInterface"] + } + ] + } + } + } + ], + "additionalProperties": false + }, + "sig": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "fallbackToRouting": { + "type": "object", + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "boolean" + } + } + }, + "sse": { + "type": "object", + "properties": { + "secureServiceEdge": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "type": "string" + } + } + }, + "secureServiceEdgeInstance": { + "properties": { + "optionType": { + "type": "string", + "enum": ["global"] + }, + "value": { + "enum": ["Cisco-Secure-Access", "zScaler"], + "type": "string" + } + } + } + }, + "required": [ + "secureServiceEdge", + "secureServiceEdgeInstance" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "secureServiceEdge": { + "properties": { + "value": { + "enum": [true] + } + } + } + } + }, + "then": { + "required": ["secureServiceEdgeInstance"] + } + } + ] + } + }, + "additionalProperties": false + }, + "allOf": [ + { + "if": { + "contains": { + "required": ["cloudSaas"] + } + }, + "then": { + "contains": { + "anyOf": [ + { + "required": ["cloudProbe"] + } + ] + } + } + }, + { + "if": { + "contains": { + "required": ["cloudSaas"] + } + }, + "then": { + "contains": { + "anyOf": [ + { + "required": ["count"] + } + ] + } + } + }, + { + "if": { + "contains": { + "anyOf": [ + { + "required": ["cloudProbe"] + }, + { + "required": ["cloudSaas"] + } + ] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["slaClass"] + }, + { + "required": ["backupSlaPreferredColor"] + }, + { + "required": ["set"] + }, + { + "required": ["redirectDns"] + }, + { + "required": ["appqoeOptimization"] + }, + { + "required": ["lossCorrection"] + }, + { + "required": ["cflowd"] + }, + { + "required": ["natPool"] + }, + { + "required": ["nat"] + }, + { + "required": ["sig"] + }, + { + "required": ["sse"] + }, + { + "required": ["fallbackToRouting"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["fallbackToRouting"] + } + }, + "then": { + "contains": { + "anyOf": [ + { + "required": ["sig"] + }, + { + "required": ["sse"] + } + ] + } + } + }, + { + "if": { + "contains": { + "required": ["sig"] + } + }, + "then": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["natPool"] + }, + { + "required": ["usevpn"] + }, + { + "required": ["sse"] + } + ] + } + } + } + }, + { + "if": { + "contains": { + "required": ["natPool"] + } + }, + "then": { + "not": { + "contains": { + "required": ["nat"] + } + } + } + } + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "baseAction": { + "properties": { + "value": { + "const": "drop" + } + } + } + } + }, + "then": { + "properties": { + "actions": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["backupSlaPreferredColor"] + }, + { + "required": ["cflowd"] + }, + { + "required": ["natPool"] + }, + { + "required": ["redirectDns"] + }, + { + "required": ["appqoeOptimization"] + }, + { + "required": ["lossCorrection"] + }, + { + "required": ["sig"] + }, + { + "required": ["fallbackToRouting"] + }, + { + "required": ["set"] + }, + { + "required": ["dscp"] + }, + { + "required": ["forwardingClass"] + }, + { + "required": ["localTlocList"] + }, + { + "required": ["perferredColorGroup"] + }, + { + "required": ["preferredRemoteColor"] + }, + { + "required": ["nextHop"] + }, + { + "required": ["nextHopIpv6"] + }, + { + "required": ["nextHopLoose"] + }, + { + "required": ["policer"] + }, + { + "required": ["service"] + }, + { + "required": ["serviceChain"] + }, + { + "required": ["tlocList"] + }, + { + "required": ["tloc"] + }, + { + "required": ["vpn"] + }, + { + "required": ["slaClass"] + }, + { + "required": ["cloudSaas"] + } + ] + } + } + } + } + } + }, + { + "anyOf": [ + { + "not": { + "required": ["actions"] + } + }, + { + "if": { + "properties": { + "actions": { + "contains": { + "required": ["redirectDns"] + } + } + } + }, + "then": { + "properties": { + "match": { + "properties": { + "entries": { + "contains": { + "oneOf": [ + { + "required": ["dnsAppList"] + }, + { + "required": ["dns"] + } + ] + } + } + } + } + } + } + }, + { + "if": { + "properties": { + "actions": { + "contains": { + "oneOf": [ + { + "required": ["cloudProbe"] + }, + { + "required": ["cloudSaas"] + } + ] + } + } + } + }, + "then": { + "properties": { + "match": { + "properties": { + "entries": { + "contains": { + "oneOf": [ + { + "required": ["appList"] + } + ] + } + } + } + } + } + } + } + ] + }, + { + "if": { + "properties": { + "sequenceIpType": { + "properties": { + "value": { + "const": "all" + } + } + } + } + }, + "then": { + "properties": { + "match": { + "properties": { + "entries": { + "not": { + "contains": { + "anyOf": [ + { + "required": ["sourceDataPrefixList"] + }, + { + "required": ["sourceDataIpv6PrefixList"] + }, + { + "required": ["destinationDataPrefixList"] + }, + { + "required": [ + "destinationDataIpv6PrefixList" + ] + } + ] + } + } + } + } + } + } + } + } + ], + "required": [], + "additionalProperties": false + } + } + }, + "required": [], + "additionalProperties": false + }, + "documentation": { + "description": "This is the documentation for POST request schema for Traffic Policy profile parcel", + "details-1": "variable name should be present with given format as specified in schema if optionType value is variable", + "details-2": "variable name should not be present if optionType value is NOT variable", + "details-3": "when option Type is global, value should be present with given format/restrictions as specified in schema", + "details-4": "when option Type is default, value should be present with given default value as specified in schema", + "examples": [ + { + "name": "traffic-policy-1", + "description": "test", + "data": { + "target": { + "vpn": { + "optionType": "global", + "value": ["Guest"] + }, + "direction": { + "optionType": "global", + "value": "service" + } + }, + "sequences": [ + { + "sequenceId": { + "optionType": "global", + "value": 1 + }, + "sequenceName": { + "optionType": "global", + "value": "traffic" + }, + "sequenceIpType": { + "optionType": "global", + "value": "ipv4" + }, + "baseAction": { + "optionType": "global", + "value": "accept" + }, + "match": { + "entries": [ + { + "appList": { + "refId": { + "optionType": "global", + "value": "31cc53c4-b2e4-41dd-a2c4-c609e8cf432c" + } + } + } + ] + }, + "actions": [ + { + "slaClass": [ + { + "slaName": { + "refId": { + "optionType": "global", + "value": "31cc53c4-b2e4-41dd-a2c4-c609e8cf432c" + } + } + }, + { + "preferredColor": { + "optionType": "global", + "value": ["gold"] + } + } + ] + }, + { + "backupSlaPreferredColor": { + "optionType": "global", + "value": ["blue"] + } + }, + { + "set": [ + { + "dscp": { + "optionType": "global", + "value": 18 + } + }, + { + "forwardingClass": { + "refId": { + "optionType": "global", + "value": "31cc53c4-b2e4-41dd-a2c4-c609e8cf432c" + } + } + } + ] + } + ] + } + ] + } + } + ] + }, + "metadata": { + "minVManageVersion": "20.15.1" + } + }, + "required": ["data"], + "not": { + "required": ["metadata"] + } + } +} diff --git a/internal/provider/data_source_sdwan_application_priority_traffic_policy_profile_parcel.go b/internal/provider/data_source_sdwan_application_priority_traffic_policy_profile_parcel.go new file mode 100644 index 00000000..79ac65ff --- /dev/null +++ b/internal/provider/data_source_sdwan_application_priority_traffic_policy_profile_parcel.go @@ -0,0 +1,504 @@ +// 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/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/netascode/go-sdwan" +) + +// End of section. //template:end imports + +// Section below is generated&owned by "gen/generator.go". //template:begin model + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &ApplicationPriorityTrafficPolicyProfileParcelDataSource{} + _ datasource.DataSourceWithConfigure = &ApplicationPriorityTrafficPolicyProfileParcelDataSource{} +) + +func NewApplicationPriorityTrafficPolicyProfileParcelDataSource() datasource.DataSource { + return &ApplicationPriorityTrafficPolicyProfileParcelDataSource{} +} + +type ApplicationPriorityTrafficPolicyProfileParcelDataSource struct { + client *sdwan.Client +} + +func (d *ApplicationPriorityTrafficPolicyProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_application_priority_traffic_policy_profile_parcel" +} + +func (d *ApplicationPriorityTrafficPolicyProfileParcelDataSource) 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 Application Priority Traffic Policy 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, + }, + "default_action": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "simple_flow": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "vpn": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "target_direction": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "sequences": schema.ListNestedAttribute{ + MarkdownDescription: "Traffic policy sequence list", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "sequence_id": schema.Int64Attribute{ + MarkdownDescription: "Sequence Id", + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "Sequence Name", + Computed: true, + }, + "base_action": schema.StringAttribute{ + MarkdownDescription: "Base Action", + Computed: true, + }, + "protocol": schema.StringAttribute{ + MarkdownDescription: "Sequence IP Type", + Computed: true, + }, + "matches": schema.ListNestedAttribute{ + MarkdownDescription: "", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "application_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "dns_application_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "dns": schema.StringAttribute{ + MarkdownDescription: "Dns", + Computed: true, + }, + "dscp": schema.Int64Attribute{ + MarkdownDescription: "DSCP number", + Computed: true, + }, + "packet_length": schema.StringAttribute{ + MarkdownDescription: "Packet Length", + Computed: true, + }, + "protocol": schema.SetAttribute{ + MarkdownDescription: "protocol (0-255) range or individual number separated by space", + ElementType: types.StringType, + Computed: true, + }, + "source_data_prefix_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "source_data_ipv6_prefix_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "source_port": schema.SetAttribute{ + MarkdownDescription: "Source Port (0-65535) range or individual number separated by space", + ElementType: types.StringType, + Computed: true, + }, + "destination_data_prefix_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "destination_data_ipv6_prefix_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "destination_port": schema.SetAttribute{ + MarkdownDescription: "Destination Port (0-65535) range or individual number separated by space", + ElementType: types.StringType, + Computed: true, + }, + "destination_region": schema.StringAttribute{ + MarkdownDescription: "Destination Region", + Computed: true, + }, + "tcp": schema.StringAttribute{ + MarkdownDescription: "TCP States", + Computed: true, + }, + "traffic_to": schema.StringAttribute{ + MarkdownDescription: "Traffic to", + Computed: true, + }, + "traffic_class": schema.StringAttribute{ + MarkdownDescription: "Traffic Class", + Computed: true, + }, + }, + }, + }, + "actions": schema.ListNestedAttribute{ + MarkdownDescription: "", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "counter": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "log": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "sla_class": schema.ListNestedAttribute{ + MarkdownDescription: "slaClass", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "sla_class_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "preferred_color": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "preferred_color_group_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "strict_drop": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "fallback_to_best_path": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "preferred_remote_color": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "remote_color_restrict": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "backup_sla_preferred_color": schema.SetAttribute{ + MarkdownDescription: "Backup SLA perferred color", + ElementType: types.StringType, + Computed: true, + }, + "sets": schema.ListNestedAttribute{ + MarkdownDescription: "", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "dscp": schema.Int64Attribute{ + MarkdownDescription: "", + Computed: true, + }, + "policer_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "preferred_color_group_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "forwarding_class_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "local_tloc_list_color": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "local_tloc_restrict": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "local_tloc_list_encapsulation": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "preferred_remote_color_id": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "preferred_remote_color_restrict": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "tloc_ip": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "tloc_color": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "tloc_encapsulation": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "tloc_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_type": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_color": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "service_encapsulation": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_tloc_ip": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_vpn": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_tloc_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_type": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_vpn": schema.Int64Attribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_local": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_fallback_to_routing": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_tloc": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "service_chain_encapsulation": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_chain_tloc_list_id": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "next_hop": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "next_hop_ipv6": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "vpn": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + "redirect_dns_field": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "redirect_dns_value": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "tcp_optimization": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "dre_optimization": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "service_node_group": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "loss_correction_type": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "loss_correct_fec_threshold": schema.Int64Attribute{ + MarkdownDescription: "", + Computed: true, + }, + "cflowd": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "nat_pool": schema.Int64Attribute{ + MarkdownDescription: "", + Computed: true, + }, + "nat_vpn": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "nat_fallback": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "nat_bypass": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "nat_dia_pool": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.Int64Type, + Computed: true, + }, + "nat_dia_interface": schema.SetAttribute{ + MarkdownDescription: "", + ElementType: types.StringType, + Computed: true, + }, + "secure_internet_gateway": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "fallback_to_routing": schema.BoolAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "secure_service_edge": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "secure_service_edge_instance": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (d *ApplicationPriorityTrafficPolicyProfileParcelDataSource) 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 *ApplicationPriorityTrafficPolicyProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config ApplicationPriorityTrafficPolicy + + // 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_application_priority_traffic_policy_profile_parcel_test.go b/internal/provider/data_source_sdwan_application_priority_traffic_policy_profile_parcel_test.go new file mode 100644 index 00000000..a08ed793 --- /dev/null +++ b/internal/provider/data_source_sdwan_application_priority_traffic_policy_profile_parcel_test.go @@ -0,0 +1,193 @@ +// 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 TestAccDataSourceSdwanApplicationPriorityTrafficPolicyProfileParcel(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_application_priority_traffic_policy_profile_parcel.test", "default_action", "accept")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "simple_flow", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "target_direction", "all")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.sequence_id", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.name", "RULE_1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.base_action", "accept")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.protocol", "ipv4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.dscp", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.packet_length", "123")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.tcp", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.traffic_to", "core")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.counter", "COUNTER_1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.log", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sla_class.0.strict_drop", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sla_class.0.fallback_to_best_path", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.dscp", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.local_tloc_restrict", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.local_tloc_list_encapsulation", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.tloc_ip", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.tloc_encapsulation", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_type", "FW")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_encapsulation", "ipsec")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_tloc_ip", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_type", "SC1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_local", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_fallback_to_routing", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_encapsulation", "ipsec")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_id", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.next_hop", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.next_hop_ipv6", "2001:0:0:1::/64")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.redirect_dns_field", "redirectDns")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.redirect_dns_value", "umbrella")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.tcp_optimization", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.dre_optimization", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.service_node_group", "SNG-APPQOE1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.loss_correction_type", "fecAdaptive")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.loss_correct_fec_threshold", "1")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.cflowd", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_pool", "2")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_vpn", "0")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_fallback", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_bypass", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.secure_internet_gateway", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.fallback_to_routing", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.secure_service_edge_instance", "zScaler")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceSdwanApplicationPriorityTrafficPolicyPrerequisitesProfileParcelConfig + testAccDataSourceSdwanApplicationPriorityTrafficPolicyProfileParcelConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAccDataSource + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccDataSourceSdwanApplicationPriorityTrafficPolicyPrerequisitesProfileParcelConfig = ` +resource "sdwan_application_priority_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 testAccDataSourceSdwanApplicationPriorityTrafficPolicyProfileParcelConfig() string { + config := `resource "sdwan_application_priority_traffic_policy_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_application_priority_feature_profile.test.id` + "\n" + config += ` default_action = "accept"` + "\n" + config += ` simple_flow = false` + "\n" + config += ` vpn = ["1"]` + "\n" + config += ` target_direction = "all"` + "\n" + config += ` sequences = [{` + "\n" + config += ` sequence_id = 1` + "\n" + config += ` name = "RULE_1"` + "\n" + config += ` base_action = "accept"` + "\n" + config += ` protocol = "ipv4"` + "\n" + config += ` matches = [{` + "\n" + config += ` dscp = 1` + "\n" + config += ` packet_length = "123"` + "\n" + config += ` protocol = ["2"]` + "\n" + config += ` tcp = "gre"` + "\n" + config += ` traffic_to = "core"` + "\n" + config += ` }]` + "\n" + config += ` actions = [{` + "\n" + config += ` counter = "COUNTER_1"` + "\n" + config += ` log = false` + "\n" + config += ` sla_class = [{` + "\n" + config += ` preferred_color = ["default"]` + "\n" + config += ` strict_drop = true` + "\n" + config += ` fallback_to_best_path = false` + "\n" + config += ` }]` + "\n" + config += ` backup_sla_preferred_color = ["default"]` + "\n" + config += ` sets = [{` + "\n" + config += ` dscp = 1` + "\n" + config += ` local_tloc_list_color = ["default"]` + "\n" + config += ` local_tloc_restrict = "false"` + "\n" + config += ` local_tloc_list_encapsulation = "gre"` + "\n" + config += ` tloc_ip = "1.2.3.4"` + "\n" + config += ` tloc_color = ["default"]` + "\n" + config += ` tloc_encapsulation = "gre"` + "\n" + config += ` service_type = "FW"` + "\n" + config += ` service_color = ["default"]` + "\n" + config += ` service_encapsulation = "ipsec"` + "\n" + config += ` service_tloc_ip = "1.2.3.4"` + "\n" + config += ` service_vpn = "1"` + "\n" + config += ` service_chain_type = "SC1"` + "\n" + config += ` service_chain_vpn = 1` + "\n" + config += ` service_chain_local = false` + "\n" + config += ` service_chain_fallback_to_routing = false` + "\n" + config += ` service_chain_tloc = ["default"]` + "\n" + config += ` service_chain_encapsulation = "ipsec"` + "\n" + config += ` service_chain_id = "1.2.3.4"` + "\n" + config += ` next_hop = "1.2.3.4"` + "\n" + config += ` next_hop_ipv6 = "2001:0:0:1::/64"` + "\n" + config += ` vpn = "1"` + "\n" + config += ` }]` + "\n" + config += ` redirect_dns_field = "redirectDns"` + "\n" + config += ` redirect_dns_value = "umbrella"` + "\n" + config += ` tcp_optimization = true` + "\n" + config += ` dre_optimization = true` + "\n" + config += ` service_node_group = "SNG-APPQOE1"` + "\n" + config += ` loss_correction_type = "fecAdaptive"` + "\n" + config += ` loss_correct_fec_threshold = 1` + "\n" + config += ` cflowd = true` + "\n" + config += ` nat_pool = 2` + "\n" + config += ` nat_vpn = 0` + "\n" + config += ` nat_fallback = false` + "\n" + config += ` nat_bypass = false` + "\n" + config += ` nat_dia_pool = [1]` + "\n" + config += ` nat_dia_interface = ["ethernet"]` + "\n" + config += ` secure_internet_gateway = true` + "\n" + config += ` fallback_to_routing = true` + "\n" + config += ` secure_service_edge_instance = "zScaler"` + "\n" + config += ` }]` + "\n" + config += ` }]` + "\n" + config += `}` + "\n" + + config += ` + data "sdwan_application_priority_traffic_policy_profile_parcel" "test" { + id = sdwan_application_priority_traffic_policy_profile_parcel.test.id + feature_profile_id = sdwan_application_priority_feature_profile.test.id + } + ` + return config +} + +// End of section. //template:end testAccDataSourceConfig diff --git a/internal/provider/model_sdwan_application_priority_traffic_policy_profile_parcel.go b/internal/provider/model_sdwan_application_priority_traffic_policy_profile_parcel.go new file mode 100644 index 00000000..e29f1cea --- /dev/null +++ b/internal/provider/model_sdwan_application_priority_traffic_policy_profile_parcel.go @@ -0,0 +1,2087 @@ +// 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/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 ApplicationPriorityTrafficPolicy 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"` + DefaultAction types.String `tfsdk:"default_action"` + SimpleFlow types.Bool `tfsdk:"simple_flow"` + Vpn types.Set `tfsdk:"vpn"` + TargetDirection types.String `tfsdk:"target_direction"` + Sequences []ApplicationPriorityTrafficPolicySequences `tfsdk:"sequences"` +} + +type ApplicationPriorityTrafficPolicySequences struct { + SequenceId types.Int64 `tfsdk:"sequence_id"` + Name types.String `tfsdk:"name"` + BaseAction types.String `tfsdk:"base_action"` + Protocol types.String `tfsdk:"protocol"` + Matches []ApplicationPriorityTrafficPolicySequencesMatches `tfsdk:"matches"` + Actions []ApplicationPriorityTrafficPolicySequencesActions `tfsdk:"actions"` +} + +type ApplicationPriorityTrafficPolicySequencesMatches struct { + ApplicationListId types.String `tfsdk:"application_list_id"` + DnsApplicationListId types.String `tfsdk:"dns_application_list_id"` + Dns types.String `tfsdk:"dns"` + Dscp types.Int64 `tfsdk:"dscp"` + PacketLength types.String `tfsdk:"packet_length"` + Protocol types.Set `tfsdk:"protocol"` + SourceDataPrefixListId types.String `tfsdk:"source_data_prefix_list_id"` + SourceDataIpv6PrefixListId types.String `tfsdk:"source_data_ipv6_prefix_list_id"` + SourcePort types.Set `tfsdk:"source_port"` + DestinationDataPrefixListId types.String `tfsdk:"destination_data_prefix_list_id"` + DestinationDataIpv6PrefixListId types.String `tfsdk:"destination_data_ipv6_prefix_list_id"` + DestinationPort types.Set `tfsdk:"destination_port"` + DestinationRegion types.String `tfsdk:"destination_region"` + Tcp types.String `tfsdk:"tcp"` + TrafficTo types.String `tfsdk:"traffic_to"` + TrafficClass types.String `tfsdk:"traffic_class"` +} +type ApplicationPriorityTrafficPolicySequencesActions struct { + Counter types.String `tfsdk:"counter"` + Log types.Bool `tfsdk:"log"` + SlaClass []ApplicationPriorityTrafficPolicySequencesActionsSlaClass `tfsdk:"sla_class"` + BackupSlaPreferredColor types.Set `tfsdk:"backup_sla_preferred_color"` + Sets []ApplicationPriorityTrafficPolicySequencesActionsSets `tfsdk:"sets"` + RedirectDnsField types.String `tfsdk:"redirect_dns_field"` + RedirectDnsValue types.String `tfsdk:"redirect_dns_value"` + TcpOptimization types.Bool `tfsdk:"tcp_optimization"` + DreOptimization types.Bool `tfsdk:"dre_optimization"` + ServiceNodeGroup types.String `tfsdk:"service_node_group"` + LossCorrectionType types.String `tfsdk:"loss_correction_type"` + LossCorrectFecThreshold types.Int64 `tfsdk:"loss_correct_fec_threshold"` + Cflowd types.Bool `tfsdk:"cflowd"` + NatPool types.Int64 `tfsdk:"nat_pool"` + NatVpn types.Bool `tfsdk:"nat_vpn"` + NatFallback types.Bool `tfsdk:"nat_fallback"` + NatBypass types.Bool `tfsdk:"nat_bypass"` + NatDiaPool types.Set `tfsdk:"nat_dia_pool"` + NatDiaInterface types.Set `tfsdk:"nat_dia_interface"` + SecureInternetGateway types.Bool `tfsdk:"secure_internet_gateway"` + FallbackToRouting types.Bool `tfsdk:"fallback_to_routing"` + SecureServiceEdge types.String `tfsdk:"secure_service_edge"` + SecureServiceEdgeInstance types.String `tfsdk:"secure_service_edge_instance"` +} + +type ApplicationPriorityTrafficPolicySequencesActionsSlaClass struct { + SlaClassListId types.String `tfsdk:"sla_class_list_id"` + PreferredColor types.Set `tfsdk:"preferred_color"` + PreferredColorGroupId types.String `tfsdk:"preferred_color_group_id"` + StrictDrop types.Bool `tfsdk:"strict_drop"` + FallbackToBestPath types.Bool `tfsdk:"fallback_to_best_path"` + PreferredRemoteColor types.Set `tfsdk:"preferred_remote_color"` + RemoteColorRestrict types.Bool `tfsdk:"remote_color_restrict"` +} +type ApplicationPriorityTrafficPolicySequencesActionsSets struct { + Dscp types.Int64 `tfsdk:"dscp"` + PolicerId types.String `tfsdk:"policer_id"` + PreferredColorGroupId types.String `tfsdk:"preferred_color_group_id"` + ForwardingClassId types.String `tfsdk:"forwarding_class_id"` + LocalTlocListColor types.Set `tfsdk:"local_tloc_list_color"` + LocalTlocRestrict types.String `tfsdk:"local_tloc_restrict"` + LocalTlocListEncapsulation types.String `tfsdk:"local_tloc_list_encapsulation"` + PreferredRemoteColorId types.Set `tfsdk:"preferred_remote_color_id"` + PreferredRemoteColorRestrict types.String `tfsdk:"preferred_remote_color_restrict"` + TlocIp types.String `tfsdk:"tloc_ip"` + TlocColor types.Set `tfsdk:"tloc_color"` + TlocEncapsulation types.String `tfsdk:"tloc_encapsulation"` + TlocListId types.String `tfsdk:"tloc_list_id"` + ServiceType types.String `tfsdk:"service_type"` + ServiceColor types.Set `tfsdk:"service_color"` + ServiceEncapsulation types.String `tfsdk:"service_encapsulation"` + ServiceTlocIp types.String `tfsdk:"service_tloc_ip"` + ServiceVpn types.String `tfsdk:"service_vpn"` + ServiceTlocListId types.String `tfsdk:"service_tloc_list_id"` + ServiceChainType types.String `tfsdk:"service_chain_type"` + ServiceChainVpn types.Int64 `tfsdk:"service_chain_vpn"` + ServiceChainLocal types.Bool `tfsdk:"service_chain_local"` + ServiceChainFallbackToRouting types.Bool `tfsdk:"service_chain_fallback_to_routing"` + ServiceChainTloc types.Set `tfsdk:"service_chain_tloc"` + ServiceChainEncapsulation types.String `tfsdk:"service_chain_encapsulation"` + ServiceChainId types.String `tfsdk:"service_chain_id"` + ServiceChainTlocListId types.String `tfsdk:"service_chain_tloc_list_id"` + NextHop types.String `tfsdk:"next_hop"` + NextHopIpv6 types.String `tfsdk:"next_hop_ipv6"` + Vpn types.String `tfsdk:"vpn"` +} + +// End of section. //template:end types + +// Section below is generated&owned by "gen/generator.go". //template:begin getModel +func (data ApplicationPriorityTrafficPolicy) getModel() string { + return "application_priority_traffic_policy" +} + +// End of section. //template:end getModel + +// Section below is generated&owned by "gen/generator.go". //template:begin getPath +func (data ApplicationPriorityTrafficPolicy) getPath() string { + return fmt.Sprintf("/v1/feature-profile/sdwan/application-priority/%v/traffic-policy", 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 ApplicationPriorityTrafficPolicy) 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.DefaultAction.IsNull() { + body, _ = sjson.Set(body, path+"dataDefaultAction.optionType", "global") + body, _ = sjson.Set(body, path+"dataDefaultAction.value", data.DefaultAction.ValueString()) + } + if !data.SimpleFlow.IsNull() { + body, _ = sjson.Set(body, path+"simpleFlow.optionType", "global") + body, _ = sjson.Set(body, path+"simpleFlow.value", data.SimpleFlow.ValueBool()) + } + if !data.Vpn.IsNull() { + body, _ = sjson.Set(body, path+"target.vpn.optionType", "global") + var values []string + data.Vpn.ElementsAs(ctx, &values, false) + body, _ = sjson.Set(body, path+"target.vpn.value", values) + } + if !data.TargetDirection.IsNull() { + body, _ = sjson.Set(body, path+"target.direction.optionType", "global") + body, _ = sjson.Set(body, path+"target.direction.value", data.TargetDirection.ValueString()) + } + body, _ = sjson.Set(body, path+"sequences", []interface{}{}) + for _, item := range data.Sequences { + itemBody := "" + if !item.SequenceId.IsNull() { + itemBody, _ = sjson.Set(itemBody, "sequenceId.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "sequenceId.value", item.SequenceId.ValueInt64()) + } + if !item.Name.IsNull() { + itemBody, _ = sjson.Set(itemBody, "sequenceName.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "sequenceName.value", item.Name.ValueString()) + } + if !item.BaseAction.IsNull() { + itemBody, _ = sjson.Set(itemBody, "baseAction.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "baseAction.value", item.BaseAction.ValueString()) + } + if !item.Protocol.IsNull() { + itemBody, _ = sjson.Set(itemBody, "sequenceIpType.optionType", "global") + itemBody, _ = sjson.Set(itemBody, "sequenceIpType.value", item.Protocol.ValueString()) + } + itemBody, _ = sjson.Set(itemBody, "match.entries", []interface{}{}) + for _, childItem := range item.Matches { + itemChildBody := "" + if !childItem.ApplicationListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "appList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "appList.refId.value", childItem.ApplicationListId.ValueString()) + } + if !childItem.DnsApplicationListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "dnsAppList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "dnsAppList.refId.value", childItem.DnsApplicationListId.ValueString()) + } + if !childItem.Dns.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "dns.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "dns.value", childItem.Dns.ValueString()) + } + if !childItem.Dscp.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "dscp.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "dscp.value", childItem.Dscp.ValueInt64()) + } + if !childItem.PacketLength.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "packetLength.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "packetLength.value", childItem.PacketLength.ValueString()) + } + if !childItem.Protocol.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "protocol.optionType", "global") + var values []string + childItem.Protocol.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "protocol.value", values) + } + if !childItem.SourceDataPrefixListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sourceDataPrefixList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "sourceDataPrefixList.refId.value", childItem.SourceDataPrefixListId.ValueString()) + } + if !childItem.SourceDataIpv6PrefixListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sourceDataIpv6PrefixList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "sourceDataIpv6PrefixList.refId.value", childItem.SourceDataIpv6PrefixListId.ValueString()) + } + if !childItem.SourcePort.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sourcePort.optionType", "global") + var values []string + childItem.SourcePort.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "sourcePort.value", values) + } + if !childItem.DestinationDataPrefixListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "destinationDataPrefixList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "destinationDataPrefixList.refId.value", childItem.DestinationDataPrefixListId.ValueString()) + } + if !childItem.DestinationDataIpv6PrefixListId.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "destinationDataIpv6PrefixList.refId.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "destinationDataIpv6PrefixList.refId.value", childItem.DestinationDataIpv6PrefixListId.ValueString()) + } + if !childItem.DestinationPort.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "destinationPort.optionType", "global") + var values []string + childItem.DestinationPort.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "destinationPort.value", values) + } + if !childItem.DestinationRegion.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "destinationRegion.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "destinationRegion.value", childItem.DestinationRegion.ValueString()) + } + if !childItem.Tcp.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "tcp.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "tcp.value", childItem.Tcp.ValueString()) + } + if !childItem.TrafficTo.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "trafficTo.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "trafficTo.value", childItem.TrafficTo.ValueString()) + } + if !childItem.TrafficClass.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "trafficClass.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "trafficClass.value", childItem.TrafficClass.ValueString()) + } + itemBody, _ = sjson.SetRaw(itemBody, "match.entries.-1", itemChildBody) + } + itemBody, _ = sjson.Set(itemBody, "actions", []interface{}{}) + for _, childItem := range item.Actions { + itemChildBody := "" + if !childItem.Counter.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "count.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "count.value", childItem.Counter.ValueString()) + } + if !childItem.Log.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "log.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "log.value", childItem.Log.ValueBool()) + } + itemChildBody, _ = sjson.Set(itemChildBody, "slaClass", []interface{}{}) + for _, childChildItem := range childItem.SlaClass { + itemChildChildBody := "" + if !childChildItem.SlaClassListId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "slaName.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "slaName.refId.value", childChildItem.SlaClassListId.ValueString()) + } + if !childChildItem.PreferredColor.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColor.optionType", "global") + var values []string + childChildItem.PreferredColor.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColor.value", values) + } + if !childChildItem.PreferredColorGroupId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColorGroup.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColorGroup.refId.value", childChildItem.PreferredColorGroupId.ValueString()) + } + if !childChildItem.StrictDrop.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "strict.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "strict.value", childChildItem.StrictDrop.ValueBool()) + } + if !childChildItem.FallbackToBestPath.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "fallbackToBestPath.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "fallbackToBestPath.value", childChildItem.FallbackToBestPath.ValueBool()) + } + if !childChildItem.PreferredRemoteColor.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.optionType", "global") + var values []string + childChildItem.PreferredRemoteColor.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.value", values) + } + if !childChildItem.RemoteColorRestrict.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "remoteColorRestrict.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "remoteColorRestrict.value", childChildItem.RemoteColorRestrict.ValueBool()) + } + itemChildBody, _ = sjson.SetRaw(itemChildBody, "slaClass.-1", itemChildChildBody) + } + if !childItem.BackupSlaPreferredColor.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "backupSlaPreferredColor.optionType", "global") + var values []string + childItem.BackupSlaPreferredColor.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "backupSlaPreferredColor.value", values) + } + itemChildBody, _ = sjson.Set(itemChildBody, "set", []interface{}{}) + for _, childChildItem := range childItem.Sets { + itemChildChildBody := "" + if !childChildItem.Dscp.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "dscp.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "dscp.value", childChildItem.Dscp.ValueInt64()) + } + if !childChildItem.PolicerId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "policer.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "policer.refId.value", childChildItem.PolicerId.ValueString()) + } + if !childChildItem.PreferredColorGroupId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColorGroup.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredColorGroup.refId.value", childChildItem.PreferredColorGroupId.ValueString()) + } + if !childChildItem.ForwardingClassId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "forwardingClass.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "forwardingClass.refId.value", childChildItem.ForwardingClassId.ValueString()) + } + if !childChildItem.LocalTlocListColor.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.color.optionType", "global") + var values []string + childChildItem.LocalTlocListColor.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.color.value", values) + } + if !childChildItem.LocalTlocRestrict.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.restrict.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.restrict.value", childChildItem.LocalTlocRestrict.ValueString()) + } + if !childChildItem.LocalTlocListEncapsulation.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.encap.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "localTlocList.encap.value", childChildItem.LocalTlocListEncapsulation.ValueString()) + } + if !childChildItem.PreferredRemoteColorId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.color.optionType", "global") + var values []string + childChildItem.PreferredRemoteColorId.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.color.value", values) + } + if !childChildItem.PreferredRemoteColorRestrict.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.remoteColorRestrict.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "preferredRemoteColor.remoteColorRestrict.value", childChildItem.PreferredRemoteColorRestrict.ValueString()) + } + if !childChildItem.TlocIp.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.ip.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.ip.value", childChildItem.TlocIp.ValueString()) + } + if !childChildItem.TlocColor.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.color.optionType", "global") + var values []string + childChildItem.TlocColor.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.color.value", values) + } + if !childChildItem.TlocEncapsulation.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.encap.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tloc.encap.value", childChildItem.TlocEncapsulation.ValueString()) + } + if !childChildItem.TlocListId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tlocList.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "tlocList.refId.value", childChildItem.TlocListId.ValueString()) + } + if !childChildItem.ServiceType.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.type.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.type.value", childChildItem.ServiceType.ValueString()) + } + if !childChildItem.ServiceColor.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.color.optionType", "global") + var values []string + childChildItem.ServiceColor.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.color.value", values) + } + if !childChildItem.ServiceEncapsulation.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.encap.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.encap.value", childChildItem.ServiceEncapsulation.ValueString()) + } + if !childChildItem.ServiceTlocIp.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.ip.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tloc.ip.value", childChildItem.ServiceTlocIp.ValueString()) + } + if !childChildItem.ServiceVpn.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.vpn.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.vpn.value", childChildItem.ServiceVpn.ValueString()) + } + if !childChildItem.ServiceTlocListId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tlocList.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "service.tlocList.refId.value", childChildItem.ServiceTlocListId.ValueString()) + } + if !childChildItem.ServiceChainType.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.type.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.type.value", childChildItem.ServiceChainType.ValueString()) + } + if !childChildItem.ServiceChainVpn.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.vpn.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.vpn.value", childChildItem.ServiceChainVpn.ValueInt64()) + } + if !childChildItem.ServiceChainLocal.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.local.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.local.value", childChildItem.ServiceChainLocal.ValueBool()) + } + if !childChildItem.ServiceChainFallbackToRouting.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.restrict.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.restrict.value", childChildItem.ServiceChainFallbackToRouting.ValueBool()) + } + if !childChildItem.ServiceChainTloc.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.color.optionType", "global") + var values []string + childChildItem.ServiceChainTloc.ElementsAs(ctx, &values, false) + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.color.value", values) + } + if !childChildItem.ServiceChainEncapsulation.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.encap.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.encap.value", childChildItem.ServiceChainEncapsulation.ValueString()) + } + if !childChildItem.ServiceChainId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.ip.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tloc.ip.value", childChildItem.ServiceChainId.ValueString()) + } + if !childChildItem.ServiceChainTlocListId.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tlocList.refId.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "serviceChain.tlocList.refId.value", childChildItem.ServiceChainTlocListId.ValueString()) + } + if !childChildItem.NextHop.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "nextHop.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "nextHop.value", childChildItem.NextHop.ValueString()) + } + if !childChildItem.NextHopIpv6.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "nextHopIpv6.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "nextHopIpv6.value", childChildItem.NextHopIpv6.ValueString()) + } + if !childChildItem.Vpn.IsNull() { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "vpn.optionType", "global") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "vpn.value", childChildItem.Vpn.ValueString()) + } + itemChildBody, _ = sjson.SetRaw(itemChildBody, "set.-1", itemChildChildBody) + } + if !childItem.RedirectDnsField.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "redirectDns.field.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "redirectDns.field.value", childItem.RedirectDnsField.ValueString()) + } + if !childItem.RedirectDnsValue.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "redirectDns.value.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "redirectDns.value.value", childItem.RedirectDnsValue.ValueString()) + } + if !childItem.TcpOptimization.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.tcpOptimization.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.tcpOptimization.value", childItem.TcpOptimization.ValueBool()) + } + if !childItem.DreOptimization.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.dreOptimization.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.dreOptimization.value", childItem.DreOptimization.ValueBool()) + } + if !childItem.ServiceNodeGroup.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.serviceNodeGroup.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "appqoeOptimization.serviceNodeGroup.value", childItem.ServiceNodeGroup.ValueString()) + } + if !childItem.LossCorrectionType.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "lossCorrection.lossCorrectionType.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "lossCorrection.lossCorrectionType.value", childItem.LossCorrectionType.ValueString()) + } + if !childItem.LossCorrectFecThreshold.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "lossCorrection.lossCorrectFec.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "lossCorrection.lossCorrectFec.value", childItem.LossCorrectFecThreshold.ValueInt64()) + } + if !childItem.Cflowd.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "cflowd.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "cflowd.value", childItem.Cflowd.ValueBool()) + } + if !childItem.NatPool.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "natPool.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "natPool.value", childItem.NatPool.ValueInt64()) + } + if !childItem.NatVpn.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "nat.useVpn.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "nat.useVpn.value", childItem.NatVpn.ValueBool()) + } + if !childItem.NatFallback.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "nat.fallback.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "nat.fallback.value", childItem.NatFallback.ValueBool()) + } + if !childItem.NatBypass.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "nat.bypass.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "nat.bypass.value", childItem.NatBypass.ValueBool()) + } + if !childItem.NatDiaPool.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "nat.diaPool.optionType", "global") + var values []int64 + childItem.NatDiaPool.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "nat.diaPool.value", values) + } + if !childItem.NatDiaInterface.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "nat.diaInterface.optionType", "global") + var values []string + childItem.NatDiaInterface.ElementsAs(ctx, &values, false) + itemChildBody, _ = sjson.Set(itemChildBody, "nat.diaInterface.value", values) + } + if !childItem.SecureInternetGateway.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sig.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "sig.value", childItem.SecureInternetGateway.ValueBool()) + } + if !childItem.FallbackToRouting.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "fallbackToRouting.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "fallbackToRouting.value", childItem.FallbackToRouting.ValueBool()) + } + if !childItem.SecureServiceEdge.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sse.secureServiceEdge.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "sse.secureServiceEdge.value", childItem.SecureServiceEdge.ValueString()) + } + if !childItem.SecureServiceEdgeInstance.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "sse.secureServiceEdgeInstance.optionType", "global") + itemChildBody, _ = sjson.Set(itemChildBody, "sse.secureServiceEdgeInstance.value", childItem.SecureServiceEdgeInstance.ValueString()) + } + itemBody, _ = sjson.SetRaw(itemBody, "actions.-1", itemChildBody) + } + body, _ = sjson.SetRaw(body, path+"sequences.-1", itemBody) + } + return body +} + +// End of section. //template:end toBody + +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody +func (data *ApplicationPriorityTrafficPolicy) 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.DefaultAction = types.StringNull() + + if t := res.Get(path + "dataDefaultAction.optionType"); t.Exists() { + va := res.Get(path + "dataDefaultAction.value") + if t.String() == "global" { + data.DefaultAction = types.StringValue(va.String()) + } + } + data.SimpleFlow = types.BoolNull() + + if t := res.Get(path + "simpleFlow.optionType"); t.Exists() { + va := res.Get(path + "simpleFlow.value") + if t.String() == "global" { + data.SimpleFlow = types.BoolValue(va.Bool()) + } + } + data.Vpn = types.SetNull(types.StringType) + + if t := res.Get(path + "target.vpn.optionType"); t.Exists() { + va := res.Get(path + "target.vpn.value") + if t.String() == "global" { + data.Vpn = helpers.GetStringSet(va.Array()) + } + } + data.TargetDirection = types.StringNull() + + if t := res.Get(path + "target.direction.optionType"); t.Exists() { + va := res.Get(path + "target.direction.value") + if t.String() == "global" { + data.TargetDirection = types.StringValue(va.String()) + } + } + if value := res.Get(path + "sequences"); value.Exists() { + data.Sequences = make([]ApplicationPriorityTrafficPolicySequences, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := ApplicationPriorityTrafficPolicySequences{} + item.SequenceId = types.Int64Null() + + if t := v.Get("sequenceId.optionType"); t.Exists() { + va := v.Get("sequenceId.value") + if t.String() == "global" { + item.SequenceId = types.Int64Value(va.Int()) + } + } + item.Name = types.StringNull() + + if t := v.Get("sequenceName.optionType"); t.Exists() { + va := v.Get("sequenceName.value") + if t.String() == "global" { + item.Name = types.StringValue(va.String()) + } + } + item.BaseAction = types.StringNull() + + if t := v.Get("baseAction.optionType"); t.Exists() { + va := v.Get("baseAction.value") + if t.String() == "global" { + item.BaseAction = types.StringValue(va.String()) + } + } + item.Protocol = types.StringNull() + + if t := v.Get("sequenceIpType.optionType"); t.Exists() { + va := v.Get("sequenceIpType.value") + if t.String() == "global" { + item.Protocol = types.StringValue(va.String()) + } + } + if cValue := v.Get("match.entries"); cValue.Exists() { + item.Matches = make([]ApplicationPriorityTrafficPolicySequencesMatches, 0) + cValue.ForEach(func(ck, cv gjson.Result) bool { + cItem := ApplicationPriorityTrafficPolicySequencesMatches{} + cItem.ApplicationListId = types.StringNull() + + if t := cv.Get("appList.refId.optionType"); t.Exists() { + va := cv.Get("appList.refId.value") + if t.String() == "global" { + cItem.ApplicationListId = types.StringValue(va.String()) + } + } + cItem.DnsApplicationListId = types.StringNull() + + if t := cv.Get("dnsAppList.refId.optionType"); t.Exists() { + va := cv.Get("dnsAppList.refId.value") + if t.String() == "global" { + cItem.DnsApplicationListId = types.StringValue(va.String()) + } + } + cItem.Dns = types.StringNull() + + if t := cv.Get("dns.optionType"); t.Exists() { + va := cv.Get("dns.value") + if t.String() == "global" { + cItem.Dns = types.StringValue(va.String()) + } + } + cItem.Dscp = types.Int64Null() + + if t := cv.Get("dscp.optionType"); t.Exists() { + va := cv.Get("dscp.value") + if t.String() == "global" { + cItem.Dscp = types.Int64Value(va.Int()) + } + } + cItem.PacketLength = types.StringNull() + + if t := cv.Get("packetLength.optionType"); t.Exists() { + va := cv.Get("packetLength.value") + if t.String() == "global" { + cItem.PacketLength = types.StringValue(va.String()) + } + } + cItem.Protocol = types.SetNull(types.StringType) + + if t := cv.Get("protocol.optionType"); t.Exists() { + va := cv.Get("protocol.value") + if t.String() == "global" { + cItem.Protocol = helpers.GetStringSet(va.Array()) + } + } + cItem.SourceDataPrefixListId = types.StringNull() + + if t := cv.Get("sourceDataPrefixList.refId.optionType"); t.Exists() { + va := cv.Get("sourceDataPrefixList.refId.value") + if t.String() == "global" { + cItem.SourceDataPrefixListId = types.StringValue(va.String()) + } + } + cItem.SourceDataIpv6PrefixListId = types.StringNull() + + if t := cv.Get("sourceDataIpv6PrefixList.refId.optionType"); t.Exists() { + va := cv.Get("sourceDataIpv6PrefixList.refId.value") + if t.String() == "global" { + cItem.SourceDataIpv6PrefixListId = types.StringValue(va.String()) + } + } + cItem.SourcePort = types.SetNull(types.StringType) + + if t := cv.Get("sourcePort.optionType"); t.Exists() { + va := cv.Get("sourcePort.value") + if t.String() == "global" { + cItem.SourcePort = helpers.GetStringSet(va.Array()) + } + } + cItem.DestinationDataPrefixListId = types.StringNull() + + if t := cv.Get("destinationDataPrefixList.refId.optionType"); t.Exists() { + va := cv.Get("destinationDataPrefixList.refId.value") + if t.String() == "global" { + cItem.DestinationDataPrefixListId = types.StringValue(va.String()) + } + } + cItem.DestinationDataIpv6PrefixListId = types.StringNull() + + if t := cv.Get("destinationDataIpv6PrefixList.refId.optionType"); t.Exists() { + va := cv.Get("destinationDataIpv6PrefixList.refId.value") + if t.String() == "global" { + cItem.DestinationDataIpv6PrefixListId = types.StringValue(va.String()) + } + } + cItem.DestinationPort = types.SetNull(types.StringType) + + if t := cv.Get("destinationPort.optionType"); t.Exists() { + va := cv.Get("destinationPort.value") + if t.String() == "global" { + cItem.DestinationPort = helpers.GetStringSet(va.Array()) + } + } + cItem.DestinationRegion = types.StringNull() + + if t := cv.Get("destinationRegion.optionType"); t.Exists() { + va := cv.Get("destinationRegion.value") + if t.String() == "global" { + cItem.DestinationRegion = types.StringValue(va.String()) + } + } + cItem.Tcp = types.StringNull() + + if t := cv.Get("tcp.optionType"); t.Exists() { + va := cv.Get("tcp.value") + if t.String() == "global" { + cItem.Tcp = types.StringValue(va.String()) + } + } + cItem.TrafficTo = types.StringNull() + + if t := cv.Get("trafficTo.optionType"); t.Exists() { + va := cv.Get("trafficTo.value") + if t.String() == "global" { + cItem.TrafficTo = types.StringValue(va.String()) + } + } + cItem.TrafficClass = types.StringNull() + + if t := cv.Get("trafficClass.optionType"); t.Exists() { + va := cv.Get("trafficClass.value") + if t.String() == "global" { + cItem.TrafficClass = types.StringValue(va.String()) + } + } + item.Matches = append(item.Matches, cItem) + return true + }) + } + if cValue := v.Get("actions"); cValue.Exists() { + item.Actions = make([]ApplicationPriorityTrafficPolicySequencesActions, 0) + cValue.ForEach(func(ck, cv gjson.Result) bool { + cItem := ApplicationPriorityTrafficPolicySequencesActions{} + cItem.Counter = types.StringNull() + + if t := cv.Get("count.optionType"); t.Exists() { + va := cv.Get("count.value") + if t.String() == "global" { + cItem.Counter = types.StringValue(va.String()) + } + } + cItem.Log = types.BoolNull() + + if t := cv.Get("log.optionType"); t.Exists() { + va := cv.Get("log.value") + if t.String() == "global" { + cItem.Log = types.BoolValue(va.Bool()) + } + } + if ccValue := cv.Get("slaClass"); ccValue.Exists() { + cItem.SlaClass = make([]ApplicationPriorityTrafficPolicySequencesActionsSlaClass, 0) + ccValue.ForEach(func(cck, ccv gjson.Result) bool { + ccItem := ApplicationPriorityTrafficPolicySequencesActionsSlaClass{} + ccItem.SlaClassListId = types.StringNull() + + if t := ccv.Get("slaName.refId.optionType"); t.Exists() { + va := ccv.Get("slaName.refId.value") + if t.String() == "global" { + ccItem.SlaClassListId = types.StringValue(va.String()) + } + } + ccItem.PreferredColor = types.SetNull(types.StringType) + + if t := ccv.Get("preferredColor.optionType"); t.Exists() { + va := ccv.Get("preferredColor.value") + if t.String() == "global" { + ccItem.PreferredColor = helpers.GetStringSet(va.Array()) + } + } + ccItem.PreferredColorGroupId = types.StringNull() + + if t := ccv.Get("preferredColorGroup.refId.optionType"); t.Exists() { + va := ccv.Get("preferredColorGroup.refId.value") + if t.String() == "global" { + ccItem.PreferredColorGroupId = types.StringValue(va.String()) + } + } + ccItem.StrictDrop = types.BoolNull() + + if t := ccv.Get("strict.optionType"); t.Exists() { + va := ccv.Get("strict.value") + if t.String() == "global" { + ccItem.StrictDrop = types.BoolValue(va.Bool()) + } + } + ccItem.FallbackToBestPath = types.BoolNull() + + if t := ccv.Get("fallbackToBestPath.optionType"); t.Exists() { + va := ccv.Get("fallbackToBestPath.value") + if t.String() == "global" { + ccItem.FallbackToBestPath = types.BoolValue(va.Bool()) + } + } + ccItem.PreferredRemoteColor = types.SetNull(types.StringType) + + if t := ccv.Get("preferredRemoteColor.optionType"); t.Exists() { + va := ccv.Get("preferredRemoteColor.value") + if t.String() == "global" { + ccItem.PreferredRemoteColor = helpers.GetStringSet(va.Array()) + } + } + ccItem.RemoteColorRestrict = types.BoolNull() + + if t := ccv.Get("remoteColorRestrict.optionType"); t.Exists() { + va := ccv.Get("remoteColorRestrict.value") + if t.String() == "global" { + ccItem.RemoteColorRestrict = types.BoolValue(va.Bool()) + } + } + cItem.SlaClass = append(cItem.SlaClass, ccItem) + return true + }) + } + cItem.BackupSlaPreferredColor = types.SetNull(types.StringType) + + if t := cv.Get("backupSlaPreferredColor.optionType"); t.Exists() { + va := cv.Get("backupSlaPreferredColor.value") + if t.String() == "global" { + cItem.BackupSlaPreferredColor = helpers.GetStringSet(va.Array()) + } + } + if ccValue := cv.Get("set"); ccValue.Exists() { + cItem.Sets = make([]ApplicationPriorityTrafficPolicySequencesActionsSets, 0) + ccValue.ForEach(func(cck, ccv gjson.Result) bool { + ccItem := ApplicationPriorityTrafficPolicySequencesActionsSets{} + ccItem.Dscp = types.Int64Null() + + if t := ccv.Get("dscp.optionType"); t.Exists() { + va := ccv.Get("dscp.value") + if t.String() == "global" { + ccItem.Dscp = types.Int64Value(va.Int()) + } + } + ccItem.PolicerId = types.StringNull() + + if t := ccv.Get("policer.refId.optionType"); t.Exists() { + va := ccv.Get("policer.refId.value") + if t.String() == "global" { + ccItem.PolicerId = types.StringValue(va.String()) + } + } + ccItem.PreferredColorGroupId = types.StringNull() + + if t := ccv.Get("preferredColorGroup.refId.optionType"); t.Exists() { + va := ccv.Get("preferredColorGroup.refId.value") + if t.String() == "global" { + ccItem.PreferredColorGroupId = types.StringValue(va.String()) + } + } + ccItem.ForwardingClassId = types.StringNull() + + if t := ccv.Get("forwardingClass.refId.optionType"); t.Exists() { + va := ccv.Get("forwardingClass.refId.value") + if t.String() == "global" { + ccItem.ForwardingClassId = types.StringValue(va.String()) + } + } + ccItem.LocalTlocListColor = types.SetNull(types.StringType) + + if t := ccv.Get("localTlocList.color.optionType"); t.Exists() { + va := ccv.Get("localTlocList.color.value") + if t.String() == "global" { + ccItem.LocalTlocListColor = helpers.GetStringSet(va.Array()) + } + } + ccItem.LocalTlocRestrict = types.StringNull() + + if t := ccv.Get("localTlocList.restrict.optionType"); t.Exists() { + va := ccv.Get("localTlocList.restrict.value") + if t.String() == "global" { + ccItem.LocalTlocRestrict = types.StringValue(va.String()) + } + } + ccItem.LocalTlocListEncapsulation = types.StringNull() + + if t := ccv.Get("localTlocList.encap.optionType"); t.Exists() { + va := ccv.Get("localTlocList.encap.value") + if t.String() == "global" { + ccItem.LocalTlocListEncapsulation = types.StringValue(va.String()) + } + } + ccItem.PreferredRemoteColorId = types.SetNull(types.StringType) + + if t := ccv.Get("preferredRemoteColor.color.optionType"); t.Exists() { + va := ccv.Get("preferredRemoteColor.color.value") + if t.String() == "global" { + ccItem.PreferredRemoteColorId = helpers.GetStringSet(va.Array()) + } + } + ccItem.PreferredRemoteColorRestrict = types.StringNull() + + if t := ccv.Get("preferredRemoteColor.remoteColorRestrict.optionType"); t.Exists() { + va := ccv.Get("preferredRemoteColor.remoteColorRestrict.value") + if t.String() == "global" { + ccItem.PreferredRemoteColorRestrict = types.StringValue(va.String()) + } + } + ccItem.TlocIp = types.StringNull() + + if t := ccv.Get("tloc.ip.optionType"); t.Exists() { + va := ccv.Get("tloc.ip.value") + if t.String() == "global" { + ccItem.TlocIp = types.StringValue(va.String()) + } + } + ccItem.TlocColor = types.SetNull(types.StringType) + + if t := ccv.Get("tloc.color.optionType"); t.Exists() { + va := ccv.Get("tloc.color.value") + if t.String() == "global" { + ccItem.TlocColor = helpers.GetStringSet(va.Array()) + } + } + ccItem.TlocEncapsulation = types.StringNull() + + if t := ccv.Get("tloc.encap.optionType"); t.Exists() { + va := ccv.Get("tloc.encap.value") + if t.String() == "global" { + ccItem.TlocEncapsulation = types.StringValue(va.String()) + } + } + ccItem.TlocListId = types.StringNull() + + if t := ccv.Get("tlocList.refId.optionType"); t.Exists() { + va := ccv.Get("tlocList.refId.value") + if t.String() == "global" { + ccItem.TlocListId = types.StringValue(va.String()) + } + } + ccItem.ServiceType = types.StringNull() + + if t := ccv.Get("service.type.optionType"); t.Exists() { + va := ccv.Get("service.type.value") + if t.String() == "global" { + ccItem.ServiceType = types.StringValue(va.String()) + } + } + ccItem.ServiceColor = types.SetNull(types.StringType) + + if t := ccv.Get("service.tloc.color.optionType"); t.Exists() { + va := ccv.Get("service.tloc.color.value") + if t.String() == "global" { + ccItem.ServiceColor = helpers.GetStringSet(va.Array()) + } + } + ccItem.ServiceEncapsulation = types.StringNull() + + if t := ccv.Get("service.tloc.encap.optionType"); t.Exists() { + va := ccv.Get("service.tloc.encap.value") + if t.String() == "global" { + ccItem.ServiceEncapsulation = types.StringValue(va.String()) + } + } + ccItem.ServiceTlocIp = types.StringNull() + + if t := ccv.Get("service.tloc.ip.optionType"); t.Exists() { + va := ccv.Get("service.tloc.ip.value") + if t.String() == "global" { + ccItem.ServiceTlocIp = types.StringValue(va.String()) + } + } + ccItem.ServiceVpn = types.StringNull() + + if t := ccv.Get("service.vpn.optionType"); t.Exists() { + va := ccv.Get("service.vpn.value") + if t.String() == "global" { + ccItem.ServiceVpn = types.StringValue(va.String()) + } + } + ccItem.ServiceTlocListId = types.StringNull() + + if t := ccv.Get("service.tlocList.refId.optionType"); t.Exists() { + va := ccv.Get("service.tlocList.refId.value") + if t.String() == "global" { + ccItem.ServiceTlocListId = types.StringValue(va.String()) + } + } + ccItem.ServiceChainType = types.StringNull() + + if t := ccv.Get("serviceChain.type.optionType"); t.Exists() { + va := ccv.Get("serviceChain.type.value") + if t.String() == "global" { + ccItem.ServiceChainType = types.StringValue(va.String()) + } + } + ccItem.ServiceChainVpn = types.Int64Null() + + if t := ccv.Get("serviceChain.vpn.optionType"); t.Exists() { + va := ccv.Get("serviceChain.vpn.value") + if t.String() == "global" { + ccItem.ServiceChainVpn = types.Int64Value(va.Int()) + } + } + ccItem.ServiceChainLocal = types.BoolNull() + + if t := ccv.Get("serviceChain.local.optionType"); t.Exists() { + va := ccv.Get("serviceChain.local.value") + if t.String() == "global" { + ccItem.ServiceChainLocal = types.BoolValue(va.Bool()) + } + } + ccItem.ServiceChainFallbackToRouting = types.BoolNull() + + if t := ccv.Get("serviceChain.restrict.optionType"); t.Exists() { + va := ccv.Get("serviceChain.restrict.value") + if t.String() == "global" { + ccItem.ServiceChainFallbackToRouting = types.BoolValue(va.Bool()) + } + } + ccItem.ServiceChainTloc = types.SetNull(types.StringType) + + if t := ccv.Get("serviceChain.tloc.color.optionType"); t.Exists() { + va := ccv.Get("serviceChain.tloc.color.value") + if t.String() == "global" { + ccItem.ServiceChainTloc = helpers.GetStringSet(va.Array()) + } + } + ccItem.ServiceChainEncapsulation = types.StringNull() + + if t := ccv.Get("serviceChain.tloc.encap.optionType"); t.Exists() { + va := ccv.Get("serviceChain.tloc.encap.value") + if t.String() == "global" { + ccItem.ServiceChainEncapsulation = types.StringValue(va.String()) + } + } + ccItem.ServiceChainId = types.StringNull() + + if t := ccv.Get("serviceChain.tloc.ip.optionType"); t.Exists() { + va := ccv.Get("serviceChain.tloc.ip.value") + if t.String() == "global" { + ccItem.ServiceChainId = types.StringValue(va.String()) + } + } + ccItem.ServiceChainTlocListId = types.StringNull() + + if t := ccv.Get("serviceChain.tlocList.refId.optionType"); t.Exists() { + va := ccv.Get("serviceChain.tlocList.refId.value") + if t.String() == "global" { + ccItem.ServiceChainTlocListId = types.StringValue(va.String()) + } + } + ccItem.NextHop = types.StringNull() + + if t := ccv.Get("nextHop.optionType"); t.Exists() { + va := ccv.Get("nextHop.value") + if t.String() == "global" { + ccItem.NextHop = types.StringValue(va.String()) + } + } + ccItem.NextHopIpv6 = types.StringNull() + + if t := ccv.Get("nextHopIpv6.optionType"); t.Exists() { + va := ccv.Get("nextHopIpv6.value") + if t.String() == "global" { + ccItem.NextHopIpv6 = types.StringValue(va.String()) + } + } + ccItem.Vpn = types.StringNull() + + if t := ccv.Get("vpn.optionType"); t.Exists() { + va := ccv.Get("vpn.value") + if t.String() == "global" { + ccItem.Vpn = types.StringValue(va.String()) + } + } + cItem.Sets = append(cItem.Sets, ccItem) + return true + }) + } + cItem.RedirectDnsField = types.StringNull() + + if t := cv.Get("redirectDns.field.optionType"); t.Exists() { + va := cv.Get("redirectDns.field.value") + if t.String() == "global" { + cItem.RedirectDnsField = types.StringValue(va.String()) + } + } + cItem.RedirectDnsValue = types.StringNull() + + if t := cv.Get("redirectDns.value.optionType"); t.Exists() { + va := cv.Get("redirectDns.value.value") + if t.String() == "global" { + cItem.RedirectDnsValue = types.StringValue(va.String()) + } + } + cItem.TcpOptimization = types.BoolNull() + + if t := cv.Get("appqoeOptimization.tcpOptimization.optionType"); t.Exists() { + va := cv.Get("appqoeOptimization.tcpOptimization.value") + if t.String() == "global" { + cItem.TcpOptimization = types.BoolValue(va.Bool()) + } + } + cItem.DreOptimization = types.BoolNull() + + if t := cv.Get("appqoeOptimization.dreOptimization.optionType"); t.Exists() { + va := cv.Get("appqoeOptimization.dreOptimization.value") + if t.String() == "global" { + cItem.DreOptimization = types.BoolValue(va.Bool()) + } + } + cItem.ServiceNodeGroup = types.StringNull() + + if t := cv.Get("appqoeOptimization.serviceNodeGroup.optionType"); t.Exists() { + va := cv.Get("appqoeOptimization.serviceNodeGroup.value") + if t.String() == "global" { + cItem.ServiceNodeGroup = types.StringValue(va.String()) + } + } + cItem.LossCorrectionType = types.StringNull() + + if t := cv.Get("lossCorrection.lossCorrectionType.optionType"); t.Exists() { + va := cv.Get("lossCorrection.lossCorrectionType.value") + if t.String() == "global" { + cItem.LossCorrectionType = types.StringValue(va.String()) + } + } + cItem.LossCorrectFecThreshold = types.Int64Null() + + if t := cv.Get("lossCorrection.lossCorrectFec.optionType"); t.Exists() { + va := cv.Get("lossCorrection.lossCorrectFec.value") + if t.String() == "global" { + cItem.LossCorrectFecThreshold = types.Int64Value(va.Int()) + } + } + cItem.Cflowd = types.BoolNull() + + if t := cv.Get("cflowd.optionType"); t.Exists() { + va := cv.Get("cflowd.value") + if t.String() == "global" { + cItem.Cflowd = types.BoolValue(va.Bool()) + } + } + cItem.NatPool = types.Int64Null() + + if t := cv.Get("natPool.optionType"); t.Exists() { + va := cv.Get("natPool.value") + if t.String() == "global" { + cItem.NatPool = types.Int64Value(va.Int()) + } + } + cItem.NatVpn = types.BoolNull() + + if t := cv.Get("nat.useVpn.optionType"); t.Exists() { + va := cv.Get("nat.useVpn.value") + if t.String() == "global" { + cItem.NatVpn = types.BoolValue(va.Bool()) + } + } + cItem.NatFallback = types.BoolNull() + + if t := cv.Get("nat.fallback.optionType"); t.Exists() { + va := cv.Get("nat.fallback.value") + if t.String() == "global" { + cItem.NatFallback = types.BoolValue(va.Bool()) + } + } + cItem.NatBypass = types.BoolNull() + + if t := cv.Get("nat.bypass.optionType"); t.Exists() { + va := cv.Get("nat.bypass.value") + if t.String() == "global" { + cItem.NatBypass = types.BoolValue(va.Bool()) + } + } + cItem.NatDiaPool = types.SetNull(types.Int64Type) + + if t := cv.Get("nat.diaPool.optionType"); t.Exists() { + va := cv.Get("nat.diaPool.value") + if t.String() == "global" { + cItem.NatDiaPool = helpers.GetInt64Set(va.Array()) + } + } + cItem.NatDiaInterface = types.SetNull(types.StringType) + + if t := cv.Get("nat.diaInterface.optionType"); t.Exists() { + va := cv.Get("nat.diaInterface.value") + if t.String() == "global" { + cItem.NatDiaInterface = helpers.GetStringSet(va.Array()) + } + } + cItem.SecureInternetGateway = types.BoolNull() + + if t := cv.Get("sig.optionType"); t.Exists() { + va := cv.Get("sig.value") + if t.String() == "global" { + cItem.SecureInternetGateway = types.BoolValue(va.Bool()) + } + } + cItem.FallbackToRouting = types.BoolNull() + + if t := cv.Get("fallbackToRouting.optionType"); t.Exists() { + va := cv.Get("fallbackToRouting.value") + if t.String() == "global" { + cItem.FallbackToRouting = types.BoolValue(va.Bool()) + } + } + cItem.SecureServiceEdge = types.StringNull() + + if t := cv.Get("sse.secureServiceEdge.optionType"); t.Exists() { + va := cv.Get("sse.secureServiceEdge.value") + if t.String() == "global" { + cItem.SecureServiceEdge = types.StringValue(va.String()) + } + } + cItem.SecureServiceEdgeInstance = types.StringNull() + + if t := cv.Get("sse.secureServiceEdgeInstance.optionType"); t.Exists() { + va := cv.Get("sse.secureServiceEdgeInstance.value") + if t.String() == "global" { + cItem.SecureServiceEdgeInstance = types.StringValue(va.String()) + } + } + item.Actions = append(item.Actions, cItem) + return true + }) + } + data.Sequences = append(data.Sequences, item) + return true + }) + } +} + +// End of section. //template:end fromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody +func (data *ApplicationPriorityTrafficPolicy) 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.DefaultAction = types.StringNull() + + if t := res.Get(path + "dataDefaultAction.optionType"); t.Exists() { + va := res.Get(path + "dataDefaultAction.value") + if t.String() == "global" { + data.DefaultAction = types.StringValue(va.String()) + } + } + data.SimpleFlow = types.BoolNull() + + if t := res.Get(path + "simpleFlow.optionType"); t.Exists() { + va := res.Get(path + "simpleFlow.value") + if t.String() == "global" { + data.SimpleFlow = types.BoolValue(va.Bool()) + } + } + data.Vpn = types.SetNull(types.StringType) + + if t := res.Get(path + "target.vpn.optionType"); t.Exists() { + va := res.Get(path + "target.vpn.value") + if t.String() == "global" { + data.Vpn = helpers.GetStringSet(va.Array()) + } + } + data.TargetDirection = types.StringNull() + + if t := res.Get(path + "target.direction.optionType"); t.Exists() { + va := res.Get(path + "target.direction.value") + if t.String() == "global" { + data.TargetDirection = types.StringValue(va.String()) + } + } + for i := range data.Sequences { + keys := [...]string{} + keyValues := [...]string{} + keyValuesVariables := [...]string{} + + var r gjson.Result + res.Get(path + "sequences").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.Sequences[i].SequenceId = types.Int64Null() + + if t := r.Get("sequenceId.optionType"); t.Exists() { + va := r.Get("sequenceId.value") + if t.String() == "global" { + data.Sequences[i].SequenceId = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Name = types.StringNull() + + if t := r.Get("sequenceName.optionType"); t.Exists() { + va := r.Get("sequenceName.value") + if t.String() == "global" { + data.Sequences[i].Name = types.StringValue(va.String()) + } + } + data.Sequences[i].BaseAction = types.StringNull() + + if t := r.Get("baseAction.optionType"); t.Exists() { + va := r.Get("baseAction.value") + if t.String() == "global" { + data.Sequences[i].BaseAction = types.StringValue(va.String()) + } + } + data.Sequences[i].Protocol = types.StringNull() + + if t := r.Get("sequenceIpType.optionType"); t.Exists() { + va := r.Get("sequenceIpType.value") + if t.String() == "global" { + data.Sequences[i].Protocol = types.StringValue(va.String()) + } + } + for ci := range data.Sequences[i].Matches { + keys := [...]string{} + keyValues := [...]string{} + keyValuesVariables := [...]string{} + + var cr gjson.Result + r.Get("match.entries").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 { + cr = v + return false + } + return true + }, + ) + data.Sequences[i].Matches[ci].ApplicationListId = types.StringNull() + + if t := cr.Get("appList.refId.optionType"); t.Exists() { + va := cr.Get("appList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].ApplicationListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].DnsApplicationListId = types.StringNull() + + if t := cr.Get("dnsAppList.refId.optionType"); t.Exists() { + va := cr.Get("dnsAppList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].DnsApplicationListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].Dns = types.StringNull() + + if t := cr.Get("dns.optionType"); t.Exists() { + va := cr.Get("dns.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].Dns = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].Dscp = types.Int64Null() + + if t := cr.Get("dscp.optionType"); t.Exists() { + va := cr.Get("dscp.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].Dscp = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Matches[ci].PacketLength = types.StringNull() + + if t := cr.Get("packetLength.optionType"); t.Exists() { + va := cr.Get("packetLength.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].PacketLength = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].Protocol = types.SetNull(types.StringType) + + if t := cr.Get("protocol.optionType"); t.Exists() { + va := cr.Get("protocol.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].Protocol = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Matches[ci].SourceDataPrefixListId = types.StringNull() + + if t := cr.Get("sourceDataPrefixList.refId.optionType"); t.Exists() { + va := cr.Get("sourceDataPrefixList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].SourceDataPrefixListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].SourceDataIpv6PrefixListId = types.StringNull() + + if t := cr.Get("sourceDataIpv6PrefixList.refId.optionType"); t.Exists() { + va := cr.Get("sourceDataIpv6PrefixList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].SourceDataIpv6PrefixListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].SourcePort = types.SetNull(types.StringType) + + if t := cr.Get("sourcePort.optionType"); t.Exists() { + va := cr.Get("sourcePort.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].SourcePort = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Matches[ci].DestinationDataPrefixListId = types.StringNull() + + if t := cr.Get("destinationDataPrefixList.refId.optionType"); t.Exists() { + va := cr.Get("destinationDataPrefixList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].DestinationDataPrefixListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].DestinationDataIpv6PrefixListId = types.StringNull() + + if t := cr.Get("destinationDataIpv6PrefixList.refId.optionType"); t.Exists() { + va := cr.Get("destinationDataIpv6PrefixList.refId.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].DestinationDataIpv6PrefixListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].DestinationPort = types.SetNull(types.StringType) + + if t := cr.Get("destinationPort.optionType"); t.Exists() { + va := cr.Get("destinationPort.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].DestinationPort = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Matches[ci].DestinationRegion = types.StringNull() + + if t := cr.Get("destinationRegion.optionType"); t.Exists() { + va := cr.Get("destinationRegion.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].DestinationRegion = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].Tcp = types.StringNull() + + if t := cr.Get("tcp.optionType"); t.Exists() { + va := cr.Get("tcp.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].Tcp = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].TrafficTo = types.StringNull() + + if t := cr.Get("trafficTo.optionType"); t.Exists() { + va := cr.Get("trafficTo.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].TrafficTo = types.StringValue(va.String()) + } + } + data.Sequences[i].Matches[ci].TrafficClass = types.StringNull() + + if t := cr.Get("trafficClass.optionType"); t.Exists() { + va := cr.Get("trafficClass.value") + if t.String() == "global" { + data.Sequences[i].Matches[ci].TrafficClass = types.StringValue(va.String()) + } + } + } + for ci := range data.Sequences[i].Actions { + keys := [...]string{} + keyValues := [...]string{} + keyValuesVariables := [...]string{} + + var cr gjson.Result + r.Get("actions").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 { + cr = v + return false + } + return true + }, + ) + data.Sequences[i].Actions[ci].Counter = types.StringNull() + + if t := cr.Get("count.optionType"); t.Exists() { + va := cr.Get("count.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Counter = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Log = types.BoolNull() + + if t := cr.Get("log.optionType"); t.Exists() { + va := cr.Get("log.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Log = types.BoolValue(va.Bool()) + } + } + for cci := range data.Sequences[i].Actions[ci].SlaClass { + keys := [...]string{} + keyValues := [...]string{} + keyValuesVariables := [...]string{} + + var ccr gjson.Result + cr.Get("slaClass").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 { + ccr = v + return false + } + return true + }, + ) + data.Sequences[i].Actions[ci].SlaClass[cci].SlaClassListId = types.StringNull() + + if t := ccr.Get("slaName.refId.optionType"); t.Exists() { + va := ccr.Get("slaName.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].SlaClassListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredColor = types.SetNull(types.StringType) + + if t := ccr.Get("preferredColor.optionType"); t.Exists() { + va := ccr.Get("preferredColor.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredColor = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredColorGroupId = types.StringNull() + + if t := ccr.Get("preferredColorGroup.refId.optionType"); t.Exists() { + va := ccr.Get("preferredColorGroup.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredColorGroupId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].StrictDrop = types.BoolNull() + + if t := ccr.Get("strict.optionType"); t.Exists() { + va := ccr.Get("strict.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].StrictDrop = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].FallbackToBestPath = types.BoolNull() + + if t := ccr.Get("fallbackToBestPath.optionType"); t.Exists() { + va := ccr.Get("fallbackToBestPath.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].FallbackToBestPath = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredRemoteColor = types.SetNull(types.StringType) + + if t := ccr.Get("preferredRemoteColor.optionType"); t.Exists() { + va := ccr.Get("preferredRemoteColor.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].PreferredRemoteColor = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].SlaClass[cci].RemoteColorRestrict = types.BoolNull() + + if t := ccr.Get("remoteColorRestrict.optionType"); t.Exists() { + va := ccr.Get("remoteColorRestrict.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SlaClass[cci].RemoteColorRestrict = types.BoolValue(va.Bool()) + } + } + } + data.Sequences[i].Actions[ci].BackupSlaPreferredColor = types.SetNull(types.StringType) + + if t := cr.Get("backupSlaPreferredColor.optionType"); t.Exists() { + va := cr.Get("backupSlaPreferredColor.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].BackupSlaPreferredColor = helpers.GetStringSet(va.Array()) + } + } + for cci := range data.Sequences[i].Actions[ci].Sets { + keys := [...]string{} + keyValues := [...]string{} + keyValuesVariables := [...]string{} + + var ccr gjson.Result + cr.Get("set").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 { + ccr = v + return false + } + return true + }, + ) + data.Sequences[i].Actions[ci].Sets[cci].Dscp = types.Int64Null() + + if t := ccr.Get("dscp.optionType"); t.Exists() { + va := ccr.Get("dscp.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].Dscp = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].PolicerId = types.StringNull() + + if t := ccr.Get("policer.refId.optionType"); t.Exists() { + va := ccr.Get("policer.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].PolicerId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].PreferredColorGroupId = types.StringNull() + + if t := ccr.Get("preferredColorGroup.refId.optionType"); t.Exists() { + va := ccr.Get("preferredColorGroup.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].PreferredColorGroupId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ForwardingClassId = types.StringNull() + + if t := ccr.Get("forwardingClass.refId.optionType"); t.Exists() { + va := ccr.Get("forwardingClass.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ForwardingClassId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocListColor = types.SetNull(types.StringType) + + if t := ccr.Get("localTlocList.color.optionType"); t.Exists() { + va := ccr.Get("localTlocList.color.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocListColor = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocRestrict = types.StringNull() + + if t := ccr.Get("localTlocList.restrict.optionType"); t.Exists() { + va := ccr.Get("localTlocList.restrict.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocRestrict = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocListEncapsulation = types.StringNull() + + if t := ccr.Get("localTlocList.encap.optionType"); t.Exists() { + va := ccr.Get("localTlocList.encap.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].LocalTlocListEncapsulation = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].PreferredRemoteColorId = types.SetNull(types.StringType) + + if t := ccr.Get("preferredRemoteColor.color.optionType"); t.Exists() { + va := ccr.Get("preferredRemoteColor.color.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].PreferredRemoteColorId = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].PreferredRemoteColorRestrict = types.StringNull() + + if t := ccr.Get("preferredRemoteColor.remoteColorRestrict.optionType"); t.Exists() { + va := ccr.Get("preferredRemoteColor.remoteColorRestrict.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].PreferredRemoteColorRestrict = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].TlocIp = types.StringNull() + + if t := ccr.Get("tloc.ip.optionType"); t.Exists() { + va := ccr.Get("tloc.ip.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].TlocIp = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].TlocColor = types.SetNull(types.StringType) + + if t := ccr.Get("tloc.color.optionType"); t.Exists() { + va := ccr.Get("tloc.color.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].TlocColor = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].TlocEncapsulation = types.StringNull() + + if t := ccr.Get("tloc.encap.optionType"); t.Exists() { + va := ccr.Get("tloc.encap.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].TlocEncapsulation = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].TlocListId = types.StringNull() + + if t := ccr.Get("tlocList.refId.optionType"); t.Exists() { + va := ccr.Get("tlocList.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].TlocListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceType = types.StringNull() + + if t := ccr.Get("service.type.optionType"); t.Exists() { + va := ccr.Get("service.type.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceType = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceColor = types.SetNull(types.StringType) + + if t := ccr.Get("service.tloc.color.optionType"); t.Exists() { + va := ccr.Get("service.tloc.color.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceColor = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceEncapsulation = types.StringNull() + + if t := ccr.Get("service.tloc.encap.optionType"); t.Exists() { + va := ccr.Get("service.tloc.encap.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceEncapsulation = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceTlocIp = types.StringNull() + + if t := ccr.Get("service.tloc.ip.optionType"); t.Exists() { + va := ccr.Get("service.tloc.ip.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceTlocIp = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceVpn = types.StringNull() + + if t := ccr.Get("service.vpn.optionType"); t.Exists() { + va := ccr.Get("service.vpn.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceVpn = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceTlocListId = types.StringNull() + + if t := ccr.Get("service.tlocList.refId.optionType"); t.Exists() { + va := ccr.Get("service.tlocList.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceTlocListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainType = types.StringNull() + + if t := ccr.Get("serviceChain.type.optionType"); t.Exists() { + va := ccr.Get("serviceChain.type.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainType = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainVpn = types.Int64Null() + + if t := ccr.Get("serviceChain.vpn.optionType"); t.Exists() { + va := ccr.Get("serviceChain.vpn.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainVpn = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainLocal = types.BoolNull() + + if t := ccr.Get("serviceChain.local.optionType"); t.Exists() { + va := ccr.Get("serviceChain.local.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainLocal = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainFallbackToRouting = types.BoolNull() + + if t := ccr.Get("serviceChain.restrict.optionType"); t.Exists() { + va := ccr.Get("serviceChain.restrict.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainFallbackToRouting = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainTloc = types.SetNull(types.StringType) + + if t := ccr.Get("serviceChain.tloc.color.optionType"); t.Exists() { + va := ccr.Get("serviceChain.tloc.color.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainTloc = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainEncapsulation = types.StringNull() + + if t := ccr.Get("serviceChain.tloc.encap.optionType"); t.Exists() { + va := ccr.Get("serviceChain.tloc.encap.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainEncapsulation = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainId = types.StringNull() + + if t := ccr.Get("serviceChain.tloc.ip.optionType"); t.Exists() { + va := ccr.Get("serviceChain.tloc.ip.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainTlocListId = types.StringNull() + + if t := ccr.Get("serviceChain.tlocList.refId.optionType"); t.Exists() { + va := ccr.Get("serviceChain.tlocList.refId.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].ServiceChainTlocListId = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].NextHop = types.StringNull() + + if t := ccr.Get("nextHop.optionType"); t.Exists() { + va := ccr.Get("nextHop.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].NextHop = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].NextHopIpv6 = types.StringNull() + + if t := ccr.Get("nextHopIpv6.optionType"); t.Exists() { + va := ccr.Get("nextHopIpv6.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].NextHopIpv6 = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].Sets[cci].Vpn = types.StringNull() + + if t := ccr.Get("vpn.optionType"); t.Exists() { + va := ccr.Get("vpn.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Sets[cci].Vpn = types.StringValue(va.String()) + } + } + } + data.Sequences[i].Actions[ci].RedirectDnsField = types.StringNull() + + if t := cr.Get("redirectDns.field.optionType"); t.Exists() { + va := cr.Get("redirectDns.field.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].RedirectDnsField = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].RedirectDnsValue = types.StringNull() + + if t := cr.Get("redirectDns.value.optionType"); t.Exists() { + va := cr.Get("redirectDns.value.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].RedirectDnsValue = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].TcpOptimization = types.BoolNull() + + if t := cr.Get("appqoeOptimization.tcpOptimization.optionType"); t.Exists() { + va := cr.Get("appqoeOptimization.tcpOptimization.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].TcpOptimization = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].DreOptimization = types.BoolNull() + + if t := cr.Get("appqoeOptimization.dreOptimization.optionType"); t.Exists() { + va := cr.Get("appqoeOptimization.dreOptimization.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].DreOptimization = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].ServiceNodeGroup = types.StringNull() + + if t := cr.Get("appqoeOptimization.serviceNodeGroup.optionType"); t.Exists() { + va := cr.Get("appqoeOptimization.serviceNodeGroup.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].ServiceNodeGroup = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].LossCorrectionType = types.StringNull() + + if t := cr.Get("lossCorrection.lossCorrectionType.optionType"); t.Exists() { + va := cr.Get("lossCorrection.lossCorrectionType.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].LossCorrectionType = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].LossCorrectFecThreshold = types.Int64Null() + + if t := cr.Get("lossCorrection.lossCorrectFec.optionType"); t.Exists() { + va := cr.Get("lossCorrection.lossCorrectFec.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].LossCorrectFecThreshold = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Actions[ci].Cflowd = types.BoolNull() + + if t := cr.Get("cflowd.optionType"); t.Exists() { + va := cr.Get("cflowd.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].Cflowd = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].NatPool = types.Int64Null() + + if t := cr.Get("natPool.optionType"); t.Exists() { + va := cr.Get("natPool.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatPool = types.Int64Value(va.Int()) + } + } + data.Sequences[i].Actions[ci].NatVpn = types.BoolNull() + + if t := cr.Get("nat.useVpn.optionType"); t.Exists() { + va := cr.Get("nat.useVpn.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatVpn = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].NatFallback = types.BoolNull() + + if t := cr.Get("nat.fallback.optionType"); t.Exists() { + va := cr.Get("nat.fallback.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatFallback = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].NatBypass = types.BoolNull() + + if t := cr.Get("nat.bypass.optionType"); t.Exists() { + va := cr.Get("nat.bypass.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatBypass = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].NatDiaPool = types.SetNull(types.Int64Type) + + if t := cr.Get("nat.diaPool.optionType"); t.Exists() { + va := cr.Get("nat.diaPool.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatDiaPool = helpers.GetInt64Set(va.Array()) + } + } + data.Sequences[i].Actions[ci].NatDiaInterface = types.SetNull(types.StringType) + + if t := cr.Get("nat.diaInterface.optionType"); t.Exists() { + va := cr.Get("nat.diaInterface.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].NatDiaInterface = helpers.GetStringSet(va.Array()) + } + } + data.Sequences[i].Actions[ci].SecureInternetGateway = types.BoolNull() + + if t := cr.Get("sig.optionType"); t.Exists() { + va := cr.Get("sig.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SecureInternetGateway = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].FallbackToRouting = types.BoolNull() + + if t := cr.Get("fallbackToRouting.optionType"); t.Exists() { + va := cr.Get("fallbackToRouting.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].FallbackToRouting = types.BoolValue(va.Bool()) + } + } + data.Sequences[i].Actions[ci].SecureServiceEdge = types.StringNull() + + if t := cr.Get("sse.secureServiceEdge.optionType"); t.Exists() { + va := cr.Get("sse.secureServiceEdge.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SecureServiceEdge = types.StringValue(va.String()) + } + } + data.Sequences[i].Actions[ci].SecureServiceEdgeInstance = types.StringNull() + + if t := cr.Get("sse.secureServiceEdgeInstance.optionType"); t.Exists() { + va := cr.Get("sse.secureServiceEdgeInstance.value") + if t.String() == "global" { + data.Sequences[i].Actions[ci].SecureServiceEdgeInstance = types.StringValue(va.String()) + } + } + } + } +} + +// End of section. //template:end updateFromBody + +// Section below is generated&owned by "gen/generator.go". //template:begin isNull +func (data *ApplicationPriorityTrafficPolicy) isNull(ctx context.Context, res gjson.Result) bool { + if !data.FeatureProfileId.IsNull() { + return false + } + if !data.DefaultAction.IsNull() { + return false + } + if !data.SimpleFlow.IsNull() { + return false + } + if !data.Vpn.IsNull() { + return false + } + if !data.TargetDirection.IsNull() { + return false + } + if len(data.Sequences) > 0 { + return false + } + return true +} + +// End of section. //template:end isNull diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 17a8bf8c..e31176c3 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -283,6 +283,7 @@ func (p *SdwanProvider) Resources(ctx context.Context) []func() resource.Resourc NewVPNInterfaceSVIFeatureTemplateResource, NewVPNInterfaceT1E1SerialFeatureTemplateResource, NewApplicationPriorityQoSPolicyProfileParcelResource, + NewApplicationPriorityTrafficPolicyProfileParcelResource, NewServiceLANVPNProfileParcelResource, NewServiceLANVPNInterfaceEthernetProfileParcelResource, NewServiceTrackerProfileParcelResource, @@ -424,6 +425,7 @@ func (p *SdwanProvider) DataSources(ctx context.Context) []func() datasource.Dat NewVPNInterfaceSVIFeatureTemplateDataSource, NewVPNInterfaceT1E1SerialFeatureTemplateDataSource, NewApplicationPriorityQoSPolicyProfileParcelDataSource, + NewApplicationPriorityTrafficPolicyProfileParcelDataSource, NewServiceLANVPNProfileParcelDataSource, NewServiceLANVPNInterfaceEthernetProfileParcelDataSource, NewServiceTrackerProfileParcelDataSource, diff --git a/internal/provider/resource_sdwan_application_priority_traffic_policy_profile_parcel.go b/internal/provider/resource_sdwan_application_priority_traffic_policy_profile_parcel.go new file mode 100644 index 00000000..f6fd47ee --- /dev/null +++ b/internal/provider/resource_sdwan_application_priority_traffic_policy_profile_parcel.go @@ -0,0 +1,755 @@ +// 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 = &ApplicationPriorityTrafficPolicyProfileParcelResource{} +var _ resource.ResourceWithImportState = &ApplicationPriorityTrafficPolicyProfileParcelResource{} + +func NewApplicationPriorityTrafficPolicyProfileParcelResource() resource.Resource { + return &ApplicationPriorityTrafficPolicyProfileParcelResource{} +} + +type ApplicationPriorityTrafficPolicyProfileParcelResource struct { + client *sdwan.Client + updateMutex *sync.Mutex +} + +func (r *ApplicationPriorityTrafficPolicyProfileParcelResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_application_priority_traffic_policy_profile_parcel" +} + +func (r *ApplicationPriorityTrafficPolicyProfileParcelResource) 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 Application Priority Traffic Policy 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, + }, + "default_action": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("drop", "accept").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("drop", "accept"), + }, + }, + "simple_flow": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + }, + "vpn": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Required: true, + }, + "target_direction": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("service", "tunnel", "all").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("service", "tunnel", "all"), + }, + }, + "sequences": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Traffic policy sequence list").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "sequence_id": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Sequence Id").AddIntegerRangeDescription(1, 65536).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 65536), + }, + }, + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Sequence Name").String, + Optional: true, + }, + "base_action": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Base Action").AddStringEnumDescription("drop", "accept").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("drop", "accept"), + }, + }, + "protocol": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Sequence IP Type").AddStringEnumDescription("ipv4", "ipv6", "all").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipv4", "ipv6", "all"), + }, + }, + "matches": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "application_list_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}`), ""), + }, + }, + "dns_application_list_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}`), ""), + }, + }, + "dns": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dns").AddStringEnumDescription("request", "response").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("request", "response"), + }, + }, + "dscp": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("DSCP number").AddIntegerRangeDescription(0, 63).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.AtMost(63), + }, + }, + "packet_length": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Packet Length").String, + Optional: true, + }, + "protocol": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("protocol (0-255) range or individual number separated by space").String, + ElementType: types.StringType, + Optional: true, + }, + "source_data_prefix_list_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}`), ""), + }, + }, + "source_data_ipv6_prefix_list_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}`), ""), + }, + }, + "source_port": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Source Port (0-65535) range or individual number separated by space").String, + ElementType: types.StringType, + Optional: true, + }, + "destination_data_prefix_list_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}`), ""), + }, + }, + "destination_data_ipv6_prefix_list_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}`), ""), + }, + }, + "destination_port": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Destination Port (0-65535) range or individual number separated by space").String, + ElementType: types.StringType, + Optional: true, + }, + "destination_region": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Destination Region").AddStringEnumDescription("primary-region", "secondary-region", "other-region").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("primary-region", "secondary-region", "other-region"), + }, + }, + "tcp": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("TCP States").AddStringEnumDescription("syn").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("syn"), + }, + }, + "traffic_to": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Traffic to").AddStringEnumDescription("core", "service", "access").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("core", "service", "access"), + }, + }, + "traffic_class": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Traffic Class").AddStringEnumDescription("gold-voip-telephony", "gold-broadcast-video", "gold-real-time-interactive", "gold-multimedia-conferencing", "gold-multimedia-streaming", "gold-network-control", "gold-signaling", "gold-ops-admin-mgmt", "gold-transactional-data", "gold-bulk-data", "silver", "bronze").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("gold-voip-telephony", "gold-broadcast-video", "gold-real-time-interactive", "gold-multimedia-conferencing", "gold-multimedia-streaming", "gold-network-control", "gold-signaling", "gold-ops-admin-mgmt", "gold-transactional-data", "gold-bulk-data", "silver", "bronze"), + }, + }, + }, + }, + }, + "actions": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "counter": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 20), + }, + }, + "log": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "sla_class": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("slaClass").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "sla_class_list_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}`), ""), + }, + }, + "preferred_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "preferred_color_group_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}`), ""), + }, + }, + "strict_drop": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "fallback_to_best_path": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "preferred_remote_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "remote_color_restrict": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + }, + }, + }, + "backup_sla_preferred_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Backup SLA perferred color").String, + ElementType: types.StringType, + Optional: true, + }, + "sets": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "dscp": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(0, 63).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.AtMost(63), + }, + }, + "policer_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}`), ""), + }, + }, + "preferred_color_group_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}`), ""), + }, + }, + "forwarding_class_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}`), ""), + }, + }, + "local_tloc_list_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "local_tloc_restrict": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "local_tloc_list_encapsulation": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ipsec", "gre").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipsec", "gre"), + }, + }, + "preferred_remote_color_id": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "preferred_remote_color_restrict": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "tloc_ip": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "tloc_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "tloc_encapsulation": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ipsec", "gre").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipsec", "gre"), + }, + }, + "tloc_list_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}`), ""), + }, + }, + "service_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("FW", "IDS", "IDP", "netsvc1", "netsvc2", "netsvc3", "netsvc4", "appqoe").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("FW", "IDS", "IDP", "netsvc1", "netsvc2", "netsvc3", "netsvc4", "appqoe"), + }, + }, + "service_color": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "service_encapsulation": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ipsec", "gre").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipsec", "gre"), + }, + }, + "service_tloc_ip": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "service_vpn": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 64), + stringvalidator.RegexMatches(regexp.MustCompile(`^\{\{[./\[\]a-zA-Z0-9_-]+\}\}$`), ""), + }, + }, + "service_tloc_list_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}`), ""), + }, + }, + "service_chain_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("SC1", "SC2", "SC4", "SC5", "SC6", "SC7", "SC8", "SC9", "SC10", "SC11", "SC12", "SC13", "SC14", "SC15", "SC16").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("SC1", "SC2", "SC4", "SC5", "SC6", "SC7", "SC8", "SC9", "SC10", "SC11", "SC12", "SC13", "SC14", "SC15", "SC16"), + }, + }, + "service_chain_vpn": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(0, 65530).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.AtMost(65530), + }, + }, + "service_chain_local": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "service_chain_fallback_to_routing": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "service_chain_tloc": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "service_chain_encapsulation": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ipsec", "gre").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipsec", "gre"), + }, + }, + "service_chain_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "service_chain_tloc_list_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}`), ""), + }, + }, + "next_hop": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "next_hop_ipv6": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "vpn": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 64), + stringvalidator.RegexMatches(regexp.MustCompile(`^\{\{[./\[\]a-zA-Z0-9_-]+\}\}$`), ""), + }, + }, + }, + }, + }, + "redirect_dns_field": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ipAddress", "redirectDns").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("ipAddress", "redirectDns"), + }, + }, + "redirect_dns_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "tcp_optimization": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "dre_optimization": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "service_node_group": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthBetween(1, 12), + stringvalidator.RegexMatches(regexp.MustCompile(`(SNG-APPQOE|(SNG-APPQOE([1-9]|[1-2][0-9]|3[0-1])))`), ""), + }, + }, + "loss_correction_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("fecAdaptive", "fecAlways", "packetDuplication").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("fecAdaptive", "fecAlways", "packetDuplication"), + }, + }, + "loss_correct_fec_threshold": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(1, 5).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 5), + }, + }, + "cflowd": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "nat_pool": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(1, 31).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 31), + }, + }, + "nat_vpn": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "nat_fallback": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "nat_bypass": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "nat_dia_pool": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.Int64Type, + Optional: true, + }, + "nat_dia_interface": schema.SetAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + ElementType: types.StringType, + Optional: true, + }, + "secure_internet_gateway": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "fallback_to_routing": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "secure_service_edge": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + "secure_service_edge_instance": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("Cisco-Secure-Access", "zScaler").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("Cisco-Secure-Access", "zScaler"), + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (r *ApplicationPriorityTrafficPolicyProfileParcelResource) 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 *ApplicationPriorityTrafficPolicyProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ApplicationPriorityTrafficPolicy + + // 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 *ApplicationPriorityTrafficPolicyProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ApplicationPriorityTrafficPolicy + + // 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 *ApplicationPriorityTrafficPolicyProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ApplicationPriorityTrafficPolicy + + // 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 *ApplicationPriorityTrafficPolicyProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ApplicationPriorityTrafficPolicy + + // 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 *ApplicationPriorityTrafficPolicyProfileParcelResource) 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_application_priority_traffic_policy_profile_parcel_test.go b/internal/provider/resource_sdwan_application_priority_traffic_policy_profile_parcel_test.go new file mode 100644 index 00000000..3965e02a --- /dev/null +++ b/internal/provider/resource_sdwan_application_priority_traffic_policy_profile_parcel_test.go @@ -0,0 +1,205 @@ +// 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 TestAccSdwanApplicationPriorityTrafficPolicyProfileParcel(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_application_priority_traffic_policy_profile_parcel.test", "default_action", "accept")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "simple_flow", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "target_direction", "all")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.sequence_id", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.name", "RULE_1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.base_action", "accept")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.protocol", "ipv4")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.dscp", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.packet_length", "123")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.tcp", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.matches.0.traffic_to", "core")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.counter", "COUNTER_1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.log", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sla_class.0.strict_drop", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sla_class.0.fallback_to_best_path", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.dscp", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.local_tloc_restrict", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.local_tloc_list_encapsulation", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.tloc_ip", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.tloc_encapsulation", "gre")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_type", "FW")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_encapsulation", "ipsec")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_tloc_ip", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_type", "SC1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_local", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_fallback_to_routing", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_encapsulation", "ipsec")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.service_chain_id", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.next_hop", "1.2.3.4")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.next_hop_ipv6", "2001:0:0:1::/64")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.sets.0.vpn", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.redirect_dns_field", "redirectDns")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.redirect_dns_value", "umbrella")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.tcp_optimization", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.dre_optimization", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.service_node_group", "SNG-APPQOE1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.loss_correction_type", "fecAdaptive")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.loss_correct_fec_threshold", "1")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.cflowd", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_pool", "2")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_vpn", "0")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_fallback", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.nat_bypass", "false")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.secure_internet_gateway", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.fallback_to_routing", "true")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_application_priority_traffic_policy_profile_parcel.test", "sequences.0.actions.0.secure_service_edge_instance", "zScaler")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccSdwanApplicationPriorityTrafficPolicyPrerequisitesProfileParcelConfig + testAccSdwanApplicationPriorityTrafficPolicyProfileParcelConfig_minimum(), + }, + { + Config: testAccSdwanApplicationPriorityTrafficPolicyPrerequisitesProfileParcelConfig + testAccSdwanApplicationPriorityTrafficPolicyProfileParcelConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +// End of section. //template:end testAcc + +// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites +const testAccSdwanApplicationPriorityTrafficPolicyPrerequisitesProfileParcelConfig = ` +resource "sdwan_application_priority_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 testAccSdwanApplicationPriorityTrafficPolicyProfileParcelConfig_minimum() string { + config := `resource "sdwan_application_priority_traffic_policy_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_MIN"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_application_priority_feature_profile.test.id` + "\n" + config += ` default_action = "accept"` + "\n" + config += ` simple_flow = false` + "\n" + config += ` vpn = ["1"]` + "\n" + config += ` target_direction = "all"` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigMinimum + +// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll +func testAccSdwanApplicationPriorityTrafficPolicyProfileParcelConfig_all() string { + config := `resource "sdwan_application_priority_traffic_policy_profile_parcel" "test" {` + "\n" + config += ` name = "TF_TEST_ALL"` + "\n" + config += ` description = "Terraform integration test"` + "\n" + config += ` feature_profile_id = sdwan_application_priority_feature_profile.test.id` + "\n" + config += ` default_action = "accept"` + "\n" + config += ` simple_flow = false` + "\n" + config += ` vpn = ["1"]` + "\n" + config += ` target_direction = "all"` + "\n" + config += ` sequences = [{` + "\n" + config += ` sequence_id = 1` + "\n" + config += ` name = "RULE_1"` + "\n" + config += ` base_action = "accept"` + "\n" + config += ` protocol = "ipv4"` + "\n" + config += ` matches = [{` + "\n" + config += ` dscp = 1` + "\n" + config += ` packet_length = "123"` + "\n" + config += ` protocol = ["2"]` + "\n" + config += ` tcp = "gre"` + "\n" + config += ` traffic_to = "core"` + "\n" + config += ` }]` + "\n" + config += ` actions = [{` + "\n" + config += ` counter = "COUNTER_1"` + "\n" + config += ` log = false` + "\n" + config += ` sla_class = [{` + "\n" + config += ` preferred_color = ["default"]` + "\n" + config += ` strict_drop = true` + "\n" + config += ` fallback_to_best_path = false` + "\n" + config += ` }]` + "\n" + config += ` backup_sla_preferred_color = ["default"]` + "\n" + config += ` sets = [{` + "\n" + config += ` dscp = 1` + "\n" + config += ` local_tloc_list_color = ["default"]` + "\n" + config += ` local_tloc_restrict = "false"` + "\n" + config += ` local_tloc_list_encapsulation = "gre"` + "\n" + config += ` tloc_ip = "1.2.3.4"` + "\n" + config += ` tloc_color = ["default"]` + "\n" + config += ` tloc_encapsulation = "gre"` + "\n" + config += ` service_type = "FW"` + "\n" + config += ` service_color = ["default"]` + "\n" + config += ` service_encapsulation = "ipsec"` + "\n" + config += ` service_tloc_ip = "1.2.3.4"` + "\n" + config += ` service_vpn = "1"` + "\n" + config += ` service_chain_type = "SC1"` + "\n" + config += ` service_chain_vpn = 1` + "\n" + config += ` service_chain_local = false` + "\n" + config += ` service_chain_fallback_to_routing = false` + "\n" + config += ` service_chain_tloc = ["default"]` + "\n" + config += ` service_chain_encapsulation = "ipsec"` + "\n" + config += ` service_chain_id = "1.2.3.4"` + "\n" + config += ` next_hop = "1.2.3.4"` + "\n" + config += ` next_hop_ipv6 = "2001:0:0:1::/64"` + "\n" + config += ` vpn = "1"` + "\n" + config += ` }]` + "\n" + config += ` redirect_dns_field = "redirectDns"` + "\n" + config += ` redirect_dns_value = "umbrella"` + "\n" + config += ` tcp_optimization = true` + "\n" + config += ` dre_optimization = true` + "\n" + config += ` service_node_group = "SNG-APPQOE1"` + "\n" + config += ` loss_correction_type = "fecAdaptive"` + "\n" + config += ` loss_correct_fec_threshold = 1` + "\n" + config += ` cflowd = true` + "\n" + config += ` nat_pool = 2` + "\n" + config += ` nat_vpn = 0` + "\n" + config += ` nat_fallback = false` + "\n" + config += ` nat_bypass = false` + "\n" + config += ` nat_dia_pool = [1]` + "\n" + config += ` nat_dia_interface = ["ethernet"]` + "\n" + config += ` secure_internet_gateway = true` + "\n" + config += ` fallback_to_routing = true` + "\n" + config += ` secure_service_edge_instance = "zScaler"` + "\n" + config += ` }]` + "\n" + config += ` }]` + "\n" + config += `}` + "\n" + return config +} + +// End of section. //template:end testAccConfigAll diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 9158f431..a44de771 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -18,6 +18,7 @@ description: |- - Add `sdwan_application_priority_feature_profile` resource and data source - Add `sdwan_application_priority_qos_policy_profile_parcel` resource and data source - Add `sdwan_transport_wan_vpn_interface_ethernet_profile_parcel` resource and data source +- Add `sdwan_application_priority_traffic_policy_profile_parcel` resource and data source ## 0.3.9